From patchwork Sat Jun 18 18:01:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9185771 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 66EAF6075F for ; Sat, 18 Jun 2016 18:01:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C92827DCE for ; Sat, 18 Jun 2016 18:01:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FC0628365; Sat, 18 Jun 2016 18:01:38 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 71C1127DCE for ; Sat, 18 Jun 2016 18:01:36 +0000 (UTC) Received: (qmail 10141 invoked by uid 550); 18 Jun 2016 18:01:33 -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: Reply-To: kernel-hardening@lists.openwall.com Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 10112 invoked from network); 18 Jun 2016 18:01:32 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=siFWgiWCrRX8VgDAHBCU0fkTB1ThI02+UaBLdue/VYM=; b=JGCkPhsHIUlEkRv9tyuP+FvSYaWWDAgQQ7k6jvWWZPjaFLWEx7pSLKddQcPzQaWqXo yGqkjFbFvcoioi1k6zl1AaFrh5IkFtE8pvTQ3l8ROCeT09zGV9ortsrAIuoR/zjLUkV0 3D3UvJwYxNKBsq4biwzIVHf/CC7f29yTnBKMc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=siFWgiWCrRX8VgDAHBCU0fkTB1ThI02+UaBLdue/VYM=; b=U2mY3loy+E3badZj0MUbgPKOg4ceXJhYpdm3KJiiXvCBS7vyhRSpbT9MWBTuRlcuF2 2YvprycVFf/LPXlyzI5THm1hZD44mVgaDzTYvFGED0mWW7XFuVmDCV5X3j4LhkSEKN5W VNNIfLZgW5nv6iTLCN1nKkjrDlhsDCnBm+0YJ6OgrniCXbpXcen8qGAfEsY8TN2JEZRW 7ePHDst3G3UDYuhzNRGtWOiqEINmPfd5+3pWyZ0y13iAJXKZPv354jBcJKiX8wpfK5GZ 5kHmx4CQ/wXYUd3PcrTswaLLlXaxreRI07sKdmNBKF3G36nYnS/XstDT24owptjttmYz citw== X-Gm-Message-State: ALyK8tLqDHzCv9UkLbYRwdQ1NH0c2IFXfrcex3+WawCgjSlQOgeDdZ1bg5COCjxO1UXnBEfz X-Received: by 10.98.93.65 with SMTP id r62mr10088009pfb.114.1466272880288; Sat, 18 Jun 2016 11:01:20 -0700 (PDT) Date: Sat, 18 Jun 2016 11:01:18 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Michal Marek , Masahiro Yamada , Emese Revfy , Laura Abbott , kernel-hardening@lists.openwall.com Message-ID: <20160618180118.GA32456@www.outflux.net> MIME-Version: 1.0 Content-Disposition: inline Subject: [kernel-hardening] [PATCH] kbuild: no gcc-plugins during cc-option tests X-Virus-Scanned: ClamAV using ClamSMTP From: Emese Revfy The gcc-plugins arguments should not be included when performing cc-option tests. Steps to reproduce: 1) make mrproper 2) make defconfig 3) enable GCC_PLUGINS, GCC_PLUGIN_CYC_COMPLEXITY 4) enable FUNCTION_TRACER (it will select other options as well) 5) make && make modules Build errors: MODPOST 18 modules ERROR: "__fentry__" [net/netfilter/xt_nat.ko] undefined! ERROR: "__fentry__" [net/netfilter/xt_mark.ko] undefined! ERROR: "__fentry__" [net/netfilter/xt_addrtype.ko] undefined! ERROR: "__fentry__" [net/netfilter/xt_LOG.ko] undefined! ERROR: "__fentry__" [net/netfilter/nf_nat_sip.ko] undefined! ERROR: "__fentry__" [net/netfilter/nf_nat_irc.ko] undefined! ERROR: "__fentry__" [net/netfilter/nf_nat_ftp.ko] undefined! ERROR: "__fentry__" [net/netfilter/nf_nat.ko] undefined! Reported-by: Laura Abbott Signed-off-by: Emese Revfy [kees: renamed variable, clarified commit message] Signed-off-by: Kees Cook --- I can carry this in my kspp tree for -next --- scripts/Kbuild.include | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 0f82314621f2..f585766989c2 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -108,16 +108,19 @@ as-option = $(call try-run,\ as-instr = $(call try-run,\ printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) +# Do not attempt to build with gcc plugins during cc-option tests. +CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) + # cc-option # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) cc-option = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) + $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2)) # cc-option-yn # Usage: flag := $(call cc-option-yn,-march=winchip-c6) cc-option-yn = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) # cc-option-align # Prefix align with either -falign or -malign @@ -127,7 +130,7 @@ cc-option-align = $(subst -functions=0,,\ # cc-disable-warning # Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) cc-disable-warning = $(call try-run,\ - $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + $(CC) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) # cc-name # Expands to either gcc or clang