From patchwork Thu Jun 4 13:49:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 11588003 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A250C739 for ; Thu, 4 Jun 2020 13:50:52 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id B9EB0207DF for ; Thu, 4 Jun 2020 13:50:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B9EB0207DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-18919-patchwork-kernel-hardening=patchwork.kernel.org@lists.openwall.com Received: (qmail 5606 invoked by uid 550); 4 Jun 2020 13:50:49 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 5573 invoked from network); 4 Jun 2020 13:50:49 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=9/mS/crSG/SbKgPicMind4lrkGlCDOUOSlUrNN+bfdo=; b=m4dFs8h9vUDwBr7qouzwEdcOVbrn/9YtmUoTcoDGi9P/7Nf7DCQstiPyfCyJBJ6bhf zmFCEO4F6uKkx5bCKM8rsxalF0sBD1ExKUlkXHna/SonyD3IX/wsfwf1ePGpMwDMbI0H 4aB/4t5GLCHx2VCHzrhGLvxZN2f744W35Mc+p8ILEyAyt5j28x4KywDq7AbLNyclaVRU tyjfklQzSepfhKxJ5BU/GS9FwEwGNixBUDC+PgtBRa9cWFl8LtCn86VH8BCFQhXl7WaN ZHYcZCEk7RVt8PTakAFXHLj9UUDoXGfc0XIf61zkypp8iZBfrVay4NNuIN0ccBdRH0hx dBXQ== X-Gm-Message-State: AOAM5303Nlo/nckn+r+Ux4SSyCMlj6GWXywAM9vKpzDqA9uV35xMjNtC qQuV742HJZcZFiYyUUr2wEo= X-Google-Smtp-Source: ABdhPJwrdWT6y2CL2LWAPgdgslvxxxcX+HXve/twLqm1KvVhxEovjWNPGDhPf/+ZcjY/tapJBcnulg== X-Received: by 2002:a05:6512:20d:: with SMTP id a13mr2649191lfo.36.1591278637579; Thu, 04 Jun 2020 06:50:37 -0700 (PDT) From: Alexander Popov To: Kees Cook , Emese Revfy , Miguel Ojeda , Masahiro Yamada , Michal Marek , Andrew Morton , Masahiro Yamada , Thiago Jung Bauermann , Luis Chamberlain , Jessica Yu , Sven Schnelle , Iurii Zaikin , Catalin Marinas , Will Deacon , Vincenzo Frascino , Thomas Gleixner , Peter Collingbourne , Naohiro Aota , Alexander Monakov , Mathias Krause , PaX Team , Brad Spengler , Laura Abbott , Florian Weimer , Alexander Popov , kernel-hardening@lists.openwall.com, linux-kbuild@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, gcc@gcc.gnu.org Cc: notify@kernel.org Subject: [PATCH 0/5] Improvements of the stackleak gcc plugin Date: Thu, 4 Jun 2020 16:49:52 +0300 Message-Id: <20200604134957.505389-1-alex.popov@linux.com> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 In this patch series I collected various improvements of the stackleak gcc plugin. The first patch excludes alloca() from the stackleak instrumentation logic to make it simpler. The second patch is the main improvement. It eliminates an unwanted side-effect of kernel code instrumentation. This patch is a deep reengineering of the idea described on grsecurity blog: https://grsecurity.net/resolving_an_unfortunate_stackleak_interaction The third patch adds 'verbose' plugin parameter for printing additional info about the kernel code instrumentation. Two other patches disable unneeded stackleak instrumentation for some files. I would like to thank Alexander Monakov for his advisory on gcc internals. This patch series was tested for gcc version 4.8, 5, 6, 7, 8, 9, and 10 on x86_64, i386 and arm64. That was done using the project 'kernel-build-containers': https://github.com/a13xp0p0v/kernel-build-containers Alexander Popov (5): gcc-plugins/stackleak: Exclude alloca() from the instrumentation logic gcc-plugins/stackleak: Use asm instrumentation to avoid useless register saving gcc-plugins/stackleak: Add 'verbose' plugin parameter gcc-plugins/stackleak: Don't instrument itself gcc-plugins/stackleak: Don't instrument vgettimeofday.c in arm64 VDSO arch/arm64/kernel/vdso/Makefile | 3 +- include/linux/compiler_attributes.h | 13 ++ kernel/Makefile | 1 + kernel/stackleak.c | 16 +- scripts/Makefile.gcc-plugins | 2 + scripts/gcc-plugins/stackleak_plugin.c | 260 ++++++++++++++++++++----- 6 files changed, 232 insertions(+), 63 deletions(-)