From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kees Cook Date: Tue, 03 Oct 2017 15:51:12 +0000 Subject: Re: [kernel-hardening] [PATCH 0/3] Makefile: Introduce CONFIG_CC_STACKPROTECTOR_AUTO Message-Id: List-Id: References: <1506972007-80614-1-git-send-email-keescook@chromium.org> <20171003100433.GA4931@leverpostej> In-Reply-To: <20171003100433.GA4931@leverpostej> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Mark Rutland Cc: Andrew Morton , Masahiro Yamada , Michal Marek , Yoshinori Sato , Rich Felker , Ingo Molnar , "David S. Miller" , Nicholas Piggin , Al Viro , Laura Abbott , linux-kbuild , LKML , linux-sh , "kernel-hardening@lists.openwall.com" On Tue, Oct 3, 2017 at 3:04 AM, Mark Rutland wrote: > Hi Kees, > > On Mon, Oct 02, 2017 at 12:20:04PM -0700, Kees Cook wrote: >> As described in the final patch: >> >> Nearly all modern compilers support a stack-protector option, and nearly >> all modern distributions enable the kernel stack-protector, so enabling >> this by default in kernel builds would make sense. However, Kconfig does >> not have knowledge of available compiler features, so it isn't safe to >> force on, as this would unconditionally break builds for the compilers >> or architectures that don't have support. Instead, this introduces a new >> option, CONFIG_CC_STACKPROTECTOR_AUTO, which attempts to discover the best >> possible stack-protector available, and will allow builds to proceed even >> if the compiler doesn't support any stack-protector. >> >> This option is made the default so that kernels built with modern >> compilers will be protected-by-default against stack buffer overflows, >> avoiding things like the recent BlueBorne attack. Selection of a specific >> stack-protector option remains available, including disabling it. > > I gave this a spin atop of v4.14-rc3 with a few arm64 toolchains I had > installed: > > * Linaro 17.08 GCC 7.1 // strong > * Linaro 17.05 GCC 6.1 // strong > * Linaro 15.08 GCC 5.1 // strong > * Linaro 14.09 GCC 4.9 // strong > * Linaro 13.06 GCC 4.8 // none > * Linaro 13.01 GCC 4.7 // none > > AFAICT, the detection is correct, and arm64 toolchains only gained stack > protector support in GCC 4.9. I manually tested GCC 4.8 and 4.7, and > got: > > warning: -fstack-protector not supported for this target [enabled by default] > > ... so that looks good to me. > > One thing I noticed was taht even when the build system detects no > support for stack-protector, it still passes -DCONFIG_CC_STACKPROTECTOR > to the toolchain. Is that expected? Oops, that's a mistake. I had a think-o in the Makefile logic. I will send a follow-up to fix it. -Kees -- Kees Cook Pixel Security From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752232AbdJCPvR (ORCPT ); Tue, 3 Oct 2017 11:51:17 -0400 Received: from mail-io0-f173.google.com ([209.85.223.173]:50120 "EHLO mail-io0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbdJCPvO (ORCPT ); Tue, 3 Oct 2017 11:51:14 -0400 X-Google-Smtp-Source: AOwi7QAmaBD64AMsGI8KnQRSspuTxK7MWc/5N53ywUNjx/0icr5vo6vvY81mwo43BLurUGVxSOMO5LcmJGzzj14VlEM= MIME-Version: 1.0 In-Reply-To: <20171003100433.GA4931@leverpostej> References: <1506972007-80614-1-git-send-email-keescook@chromium.org> <20171003100433.GA4931@leverpostej> From: Kees Cook Date: Tue, 3 Oct 2017 08:51:12 -0700 X-Google-Sender-Auth: Nt_lJxDsBEJDudzw6LgZNTlH8EQ Message-ID: Subject: Re: [kernel-hardening] [PATCH 0/3] Makefile: Introduce CONFIG_CC_STACKPROTECTOR_AUTO To: Mark Rutland Cc: Andrew Morton , Masahiro Yamada , Michal Marek , Yoshinori Sato , Rich Felker , Ingo Molnar , "David S. Miller" , Nicholas Piggin , Al Viro , Laura Abbott , linux-kbuild , LKML , linux-sh , "kernel-hardening@lists.openwall.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 3, 2017 at 3:04 AM, Mark Rutland wrote: > Hi Kees, > > On Mon, Oct 02, 2017 at 12:20:04PM -0700, Kees Cook wrote: >> As described in the final patch: >> >> Nearly all modern compilers support a stack-protector option, and nearly >> all modern distributions enable the kernel stack-protector, so enabling >> this by default in kernel builds would make sense. However, Kconfig does >> not have knowledge of available compiler features, so it isn't safe to >> force on, as this would unconditionally break builds for the compilers >> or architectures that don't have support. Instead, this introduces a new >> option, CONFIG_CC_STACKPROTECTOR_AUTO, which attempts to discover the best >> possible stack-protector available, and will allow builds to proceed even >> if the compiler doesn't support any stack-protector. >> >> This option is made the default so that kernels built with modern >> compilers will be protected-by-default against stack buffer overflows, >> avoiding things like the recent BlueBorne attack. Selection of a specific >> stack-protector option remains available, including disabling it. > > I gave this a spin atop of v4.14-rc3 with a few arm64 toolchains I had > installed: > > * Linaro 17.08 GCC 7.1 // strong > * Linaro 17.05 GCC 6.1 // strong > * Linaro 15.08 GCC 5.1 // strong > * Linaro 14.09 GCC 4.9 // strong > * Linaro 13.06 GCC 4.8 // none > * Linaro 13.01 GCC 4.7 // none > > AFAICT, the detection is correct, and arm64 toolchains only gained stack > protector support in GCC 4.9. I manually tested GCC 4.8 and 4.7, and > got: > > warning: -fstack-protector not supported for this target [enabled by default] > > ... so that looks good to me. > > One thing I noticed was taht even when the build system detects no > support for stack-protector, it still passes -DCONFIG_CC_STACKPROTECTOR > to the toolchain. Is that expected? Oops, that's a mistake. I had a think-o in the Makefile logic. I will send a follow-up to fix it. -Kees -- Kees Cook Pixel Security From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io0-f177.google.com ([209.85.223.177]:55998 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752048AbdJCPvO (ORCPT ); Tue, 3 Oct 2017 11:51:14 -0400 Received: by mail-io0-f177.google.com with SMTP id z187so8038752ioz.12 for ; Tue, 03 Oct 2017 08:51:14 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20171003100433.GA4931@leverpostej> References: <1506972007-80614-1-git-send-email-keescook@chromium.org> <20171003100433.GA4931@leverpostej> From: Kees Cook Date: Tue, 3 Oct 2017 08:51:12 -0700 Message-ID: Subject: Re: [kernel-hardening] [PATCH 0/3] Makefile: Introduce CONFIG_CC_STACKPROTECTOR_AUTO Content-Type: text/plain; charset="UTF-8" Sender: linux-kbuild-owner@vger.kernel.org List-ID: To: Mark Rutland Cc: Andrew Morton , Masahiro Yamada , Michal Marek , Yoshinori Sato , Rich Felker , Ingo Molnar , "David S. Miller" , Nicholas Piggin , Al Viro , Laura Abbott , linux-kbuild , LKML , linux-sh , "kernel-hardening@lists.openwall.com" On Tue, Oct 3, 2017 at 3:04 AM, Mark Rutland wrote: > Hi Kees, > > On Mon, Oct 02, 2017 at 12:20:04PM -0700, Kees Cook wrote: >> As described in the final patch: >> >> Nearly all modern compilers support a stack-protector option, and nearly >> all modern distributions enable the kernel stack-protector, so enabling >> this by default in kernel builds would make sense. However, Kconfig does >> not have knowledge of available compiler features, so it isn't safe to >> force on, as this would unconditionally break builds for the compilers >> or architectures that don't have support. Instead, this introduces a new >> option, CONFIG_CC_STACKPROTECTOR_AUTO, which attempts to discover the best >> possible stack-protector available, and will allow builds to proceed even >> if the compiler doesn't support any stack-protector. >> >> This option is made the default so that kernels built with modern >> compilers will be protected-by-default against stack buffer overflows, >> avoiding things like the recent BlueBorne attack. Selection of a specific >> stack-protector option remains available, including disabling it. > > I gave this a spin atop of v4.14-rc3 with a few arm64 toolchains I had > installed: > > * Linaro 17.08 GCC 7.1 // strong > * Linaro 17.05 GCC 6.1 // strong > * Linaro 15.08 GCC 5.1 // strong > * Linaro 14.09 GCC 4.9 // strong > * Linaro 13.06 GCC 4.8 // none > * Linaro 13.01 GCC 4.7 // none > > AFAICT, the detection is correct, and arm64 toolchains only gained stack > protector support in GCC 4.9. I manually tested GCC 4.8 and 4.7, and > got: > > warning: -fstack-protector not supported for this target [enabled by default] > > ... so that looks good to me. > > One thing I noticed was taht even when the build system detects no > support for stack-protector, it still passes -DCONFIG_CC_STACKPROTECTOR > to the toolchain. Is that expected? Oops, that's a mistake. I had a think-o in the Makefile logic. I will send a follow-up to fix it. -Kees -- Kees Cook Pixel Security