From patchwork Mon Oct 2 19:20:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9981175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8BFA4603FF for ; Mon, 2 Oct 2017 19:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E07A288C4 for ; Mon, 2 Oct 2017 19:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72FF928929; Mon, 2 Oct 2017 19:20:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6382E288D8 for ; Mon, 2 Oct 2017 19:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751667AbdJBTUj (ORCPT ); Mon, 2 Oct 2017 15:20:39 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:47159 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751359AbdJBTUS (ORCPT ); Mon, 2 Oct 2017 15:20:18 -0400 Received: by mail-pg0-f45.google.com with SMTP id r25so1078965pgn.4 for ; Mon, 02 Oct 2017 12:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zh0hGZ8XrD3wLqFJKCOca1QQd4Gg9v4mQnWKeDQGGxQ=; b=ZHR/W0MFTMpM/wBQeogmLKqo0UwfA5lmE+zJF9n7HFnItIRapXIzOhMWg7R6PK0jG5 kmDNh+Eq/MdCHULaPw3qc4lApNR/tx/INODtGLHiDyAsGOm7SdEPdA8bLn1LUj6TlmsN rBeugTYE8xTKTPKJHVveXbMdQuQyhUTuRrgV0= 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:in-reply-to :references; bh=zh0hGZ8XrD3wLqFJKCOca1QQd4Gg9v4mQnWKeDQGGxQ=; b=HZmAWNGT8a61IFtylSTijv1WOYuJwITX/c2FH8eogMtKjDEIjyckYxa045B4wVIhDv RBnMHr3kr6qXHFW05kju4jQxTydSxcky+QJihacgYKXgO+gzk0MpAmOXobtpxu/XcRgD jHCCrX+E8mHCb+jT2fkYzG6nyoIR1yeHLm0tx0v5+mFhQ/KA4VEiDV0f2BZ6B/bx8dp3 MrdEWW83EC2BErW6LmVq7xN9s5uEEWm1Z7DRRrVuopITQn6CUF3AXNyzpxpyrkayGrvT 38pe37CXSMCnQKrfjtEW62NUThKmkALKYoVSNBnPKuQ82Ho4RPd6elrD7MYUe83uuLnk XGvA== X-Gm-Message-State: AHPjjUi/NqkVhwAvl0HFn7lGoECSzdxpKyNjView6FF8ikViNmNXPTkq lp3RUqHnQh4LF7K85XiHgKJmEw== X-Google-Smtp-Source: AOwi7QA1D1FbR8cTx4NihgUVWcAvMPPi3aeOMJNPBi9vAga6sGKYl4g1LQv4W6SaiFbF37fs9eANXg== X-Received: by 10.98.209.73 with SMTP id t9mr15389042pfl.52.1506972017242; Mon, 02 Oct 2017 12:20:17 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id e66sm16580697pfb.48.2017.10.02.12.20.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 12:20:12 -0700 (PDT) From: Kees Cook To: Andrew Morton Cc: Kees Cook , Masahiro Yamada , Michal Marek , Ingo Molnar , Laura Abbott , Nicholas Piggin , Al Viro , linux-kbuild@vger.kernel.org, Yoshinori Sato , Rich Felker , "David S. Miller" , linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH 2/3] Makefile: Move stackprotector availability out of Kconfig Date: Mon, 2 Oct 2017 12:20:06 -0700 Message-Id: <1506972007-80614-3-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506972007-80614-1-git-send-email-keescook@chromium.org> References: <1506972007-80614-1-git-send-email-keescook@chromium.org> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Various portions of the kernel, especially per-architecture pieces, need to know if the compiler is building it with the stack protector. This was done in the arch/Kconfig with 'select', but this doesn't allow a way to do auto-detected compiler support. In preparation for creating an on-if-available default, move the logic for the definition of CONFIG_CC_STACKPROTECTOR into the Makefile. Cc: Masahiro Yamada Cc: Michal Marek Cc: Andrew Morton Cc: Ingo Molnar Cc: Laura Abbott Cc: Nicholas Piggin Cc: Al Viro Cc: linux-kbuild@vger.kernel.org Signed-off-by: Kees Cook --- Makefile | 7 +++++-- arch/Kconfig | 8 -------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d1119941261c..e122a9cf0399 100644 --- a/Makefile +++ b/Makefile @@ -688,8 +688,11 @@ else stackp-flag := $(call cc-option, -fno-stack-protector) endif endif -# Find arch-specific stack protector compiler sanity-checking script. -ifdef CONFIG_CC_STACKPROTECTOR +ifdef stackp-name + # If the stack protector has been selected, inform the rest of the build. + KBUILD_CFLAGS += -DCONFIG_CC_STACKPROTECTOR + KBUILD_AFLAGS += -DCONFIG_CC_STACKPROTECTOR + # Find arch-specific stack protector compiler sanity-checking script. stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh stackp-check := $(wildcard $(stackp-path)) endif diff --git a/arch/Kconfig b/arch/Kconfig index 1aafb4efbb51..7007c1bfa79c 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -523,12 +523,6 @@ config HAVE_CC_STACKPROTECTOR - its compiler supports the -fstack-protector option - it has implemented a stack canary (e.g. __stack_chk_guard) -config CC_STACKPROTECTOR - def_bool n - help - Set when a stack-protector mode is enabled, so that the build - can enable kernel-side support for the GCC feature. - choice prompt "Stack Protector buffer overflow detection" depends on HAVE_CC_STACKPROTECTOR @@ -549,7 +543,6 @@ config CC_STACKPROTECTOR_NONE config CC_STACKPROTECTOR_REGULAR bool "Regular" - select CC_STACKPROTECTOR help Functions will have the stack-protector canary logic added if they have an 8-byte or larger character array on the stack. @@ -563,7 +556,6 @@ config CC_STACKPROTECTOR_REGULAR config CC_STACKPROTECTOR_STRONG bool "Strong" - select CC_STACKPROTECTOR help Functions will have the stack-protector canary logic added in any of the following conditions: