From patchwork Sat Oct 3 15:20:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ujjwal Kumar X-Patchwork-Id: 11815315 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 BC7DA92C for ; Sat, 3 Oct 2020 15:20:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C7FC206DD for ; Sat, 3 Oct 2020 15:20:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fCtR6Dln" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725787AbgJCPUW (ORCPT ); Sat, 3 Oct 2020 11:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbgJCPUW (ORCPT ); Sat, 3 Oct 2020 11:20:22 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F8BFC0613D0; Sat, 3 Oct 2020 08:20:22 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id nl2so803583pjb.1; Sat, 03 Oct 2020 08:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=CxbBf0VRe0OZIyWTwmQLbfkYS+f/I5q5WzqukLpPtqk=; b=fCtR6DlnazI9qSvmWO5CT3uqVuXeQBmf20Vfz9o3tHYLhPd/0StGuPQhxHsfc1RCBB dv++7Y7psyh6Uy/4JY/1qv6iZJ3Ua4nKFt0xqdwepxekoOXg0YEVtE/V2saQUplEfd87 P/bjbWinHFpzTfhm+1DELqxO0BYLr8uTDRSrhGYbnbtWbp1kUjVsvJ0VwkQVaHM2kxN8 N8xTjrw5/08nKtX3OZSRnf2s7PJZ9QT+Cm7za9aShaXMJ8HiM6SWMj8lEo1phVy0mL/5 GtSU89e7o8EDi/Ml0FqlcOyo4QnYN77P0J7l8/6NMqmSFajV3EhosJbG5pNpw83NZNCU l3OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=CxbBf0VRe0OZIyWTwmQLbfkYS+f/I5q5WzqukLpPtqk=; b=UeRFejdsvq+fXIcrvwW6+VxBPCo8ucetd53DCeyJ+Omvml/u5yA2nbY2k1lTs0Skor IsNnWWpnABrTM550NbJr+OEmZyjT06+sD9pcD16L8jsoj0V54Ixyl1cNXk+kAD4652aB ijy85X1OTkpn+bkguN6SOJ5boOfA1egCjL9WXLbQgcZjq5Ebtvr99uCCsfjCntE76knW wVkJjhJSD94ImRnJoMMwSYjppeR4aXkWEUuFr2uWulWfIr9qWbee4l8PmugiLy12WaCO vfurJDQzkKy4rkV9OG+j4bm8p+3jteqASlh1lO0OM7kJajN0Rj6ttxWmC40ISI2nZdbq YAMw== X-Gm-Message-State: AOAM530kJgzHzkgfqcDuZ+vUPrBYjO2dgfg+Bv9nGZrHyRV0aKv1vci+ r4UTMI5wEr8UyteUZWUKhtg= X-Google-Smtp-Source: ABdhPJy2Skm/VPVg7z22QJtKKPWXCALWQTMav1tindWxFDZQ8sVDEn9Ongevaa02uR8olRZyamE9IQ== X-Received: by 2002:a17:90b:140c:: with SMTP id jo12mr8029928pjb.41.1601738421556; Sat, 03 Oct 2020 08:20:21 -0700 (PDT) Received: from localhost.localdomain ([2405:201:a404:280a:90bd:7a49:dcda:1fb1]) by smtp.gmail.com with ESMTPSA id e13sm5071942pjy.38.2020.10.03.08.20.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Oct 2020 08:20:20 -0700 (PDT) From: Ujjwal Kumar Subject: [PATCH RFC 1/2] kconfig: use interpreters to invoke scripts To: Masahiro Yamada , Michal Marek Cc: Ujjwal Kumar , Andrew Morton , Kees Cook , Lukas Bulwahn , Nathan Chancellor , Nick Desaulniers , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org Message-ID: Date: Sat, 3 Oct 2020 20:50:10 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org We cannot rely on execute bits to be set on files in the repository. The build script should use the explicit interpreter when invoking any script from the repository. Link: https://lore.kernel.org/lkml/20200830174409.c24c3f67addcce0cea9a9d4c@linux-foundation.org/ Link: https://lore.kernel.org/lkml/202008271102.FEB906C88@keescook/ Suggested-by: Andrew Morton Suggested-by: Kees Cook Suggested-by: Lukas Bulwahn Signed-off-by: Ujjwal Kumar Tested-by: Lukas Bulwahn Reviewed-by: Nathan Chancellor --- init/Kconfig | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 91456ac0ef20..524f6b555945 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -30,12 +30,12 @@ config CC_IS_GCC config GCC_VERSION int - default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC + default $(shell,$(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC default 0 config LD_VERSION int - default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh) + default $(shell,$(LD) --version | $(AWK) -f $(srctree)/scripts/ld-version.sh) config CC_IS_CLANG def_bool $(success,echo "$(CC_VERSION_TEXT)" | grep -q clang) @@ -45,20 +45,20 @@ config LD_IS_LLD config CLANG_VERSION int - default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) + default $(shell,$(CONFIG_SHELL) $(srctree)/scripts/clang-version.sh $(CC)) config CC_CAN_LINK bool - default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT - default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag)) + default $(success,$(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag)) if 64BIT + default $(success,$(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag)) config CC_CAN_LINK_STATIC bool - default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag) -static) if 64BIT - default $(success,$(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag) -static) + default $(success,$(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m64-flag) -static) if 64BIT + default $(success,$(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC) $(CLANG_FLAGS) $(m32-flag) -static) config CC_HAS_ASM_GOTO - def_bool $(success,$(srctree)/scripts/gcc-goto.sh $(CC)) + def_bool $(success,$(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)) config CC_HAS_ASM_GOTO_OUTPUT depends on CC_HAS_ASM_GOTO From patchwork Sat Oct 3 15:21:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ujjwal Kumar X-Patchwork-Id: 11815319 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 63E8B6CB for ; Sat, 3 Oct 2020 15:21:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 417F120709 for ; Sat, 3 Oct 2020 15:21:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NUELTX9M" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725766AbgJCPVf (ORCPT ); Sat, 3 Oct 2020 11:21:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbgJCPVf (ORCPT ); Sat, 3 Oct 2020 11:21:35 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BF7AC0613D0; Sat, 3 Oct 2020 08:21:35 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id t23so2032630pji.0; Sat, 03 Oct 2020 08:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=l/P8bXlpdS7hKkb+vBkGufM4cQSzKzU38G16UO2xhSM=; b=NUELTX9MYZwZ0qmChVIpQMZOA0R9gQhtJcKJYEIyKt4hhCQmyKRQ5xWatQFdNGz8i3 n5/4m0w01n8bu0nEqZz9+BZAJf8xV2EaJEIVzNRxqoWb15tw6QM607TuLmnma2j+U1cQ 7AjciRCBSUIs3WL5VW5YN778QV/uLAX4V4hvfaCGkPAzcUX3kHU/0MArU35FXsIhLdC8 o3YgTXVyfJ4/PfF8xzmFUibii6/VwBf5ozxeMGXBRr6SPD0z4l+N3g2h7wQrJQntBYy2 c+vS/eY0buy5tZ/sBpvezeca4zdKX5joK3Vu7BVpyF/oeTNpPTlYfhvNNrRiTcFVWGfS TQdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=l/P8bXlpdS7hKkb+vBkGufM4cQSzKzU38G16UO2xhSM=; b=uRyNg1N8nxk8ZRFQXhe/A7Slr8IZFRlKLjGyxWSJMi+/U0jFXEkYMsG2oOmn3s0FSw I7icBtHsCRcRtpTkm9m6FJkVAqDjesAFdGo7TWp3zUUN2/19S7l5aTbS5BLVVdSp+cwn rFe/9bskTtazIOWHpBGtKNNRajCN2j3qoSLqyAk7993jg904HEtsIAqbSF8tQpo0BCA9 vW4f9voZZLPmoF77UN2q8H+Y2Mm9pE0l+tAx+FZk834LGBfWs2xtjawwJC4etVy/sg9c 4Z0zjSjK6E1ATC148Ug/5Z/THwi0wXFVSbgaj0D9lBasj4cK1nXwe4ivCcTLZqsoeVYZ OKiA== X-Gm-Message-State: AOAM533HFdcK3WVt4WVzRZjsnBXo28O3c9c6h0mLMBZOZxMSgZ/SDkOz prdsVHqY3ndISi8TxHSiaU4= X-Google-Smtp-Source: ABdhPJyxBf1T0SKtqw6BFlG+BT+UZXKVLEtyAshw6qptV6ujOfLJmmBb4FxK5J5YBtLNAf01yiAh/w== X-Received: by 2002:a17:90a:1189:: with SMTP id e9mr3196782pja.124.1601738494919; Sat, 03 Oct 2020 08:21:34 -0700 (PDT) Received: from localhost.localdomain ([2405:201:a404:280a:90bd:7a49:dcda:1fb1]) by smtp.gmail.com with ESMTPSA id n125sm6026241pfn.185.2020.10.03.08.21.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Oct 2020 08:21:34 -0700 (PDT) From: Ujjwal Kumar Subject: [PATCH RFC 2/2] kbuild: use interpreters to invoke scripts To: Masahiro Yamada , Michal Marek Cc: Ujjwal Kumar , Andrew Morton , Kees Cook , Lukas Bulwahn , Nathan Chancellor , Nick Desaulniers , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, clang-built-linux@googlegroups.com, linux-kernel-mentees@lists.linuxfoundation.org Message-ID: <979bb7b0-2cae-3cd7-2fbd-7fcece9aafd1@gmail.com> Date: Sat, 3 Oct 2020 20:51:23 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org We cannot rely on execute bits to be set on files in the repository. The build script should use the explicit interpreter when invoking any script from the repository. Link: https://lore.kernel.org/lkml/20200830174409.c24c3f67addcce0cea9a9d4c@linux-foundation.org/ Link: https://lore.kernel.org/lkml/202008271102.FEB906C88@keescook/ Suggested-by: Andrew Morton Suggested-by: Kees Cook Suggested-by: Lukas Bulwahn Signed-off-by: Ujjwal Kumar Reviewed-by: Nathan Chancellor --- Makefile | 4 ++-- arch/arm64/kernel/vdso/Makefile | 2 +- arch/arm64/kernel/vdso32/Makefile | 2 +- arch/ia64/Makefile | 4 ++-- arch/nds32/kernel/vdso/Makefile | 2 +- scripts/Makefile.build | 2 +- scripts/Makefile.package | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index f93dbae71248..5f1399a576d4 100644 --- a/Makefile +++ b/Makefile @@ -1258,7 +1258,7 @@ include/generated/utsrelease.h: include/config/kernel.release FORCE PHONY += headerdep headerdep: $(Q)find $(srctree)/include/ -name '*.h' | xargs --max-args 1 \ - $(srctree)/scripts/headerdep.pl -I$(srctree)/include + $(PERL) $(srctree)/scripts/headerdep.pl -I$(srctree)/include # --------------------------------------------------------------------------- # Kernel headers @@ -1314,7 +1314,7 @@ PHONY += kselftest-merge kselftest-merge: $(if $(wildcard $(objtree)/.config),, $(error No .config exists, config your kernel first!)) $(Q)find $(srctree)/tools/testing/selftests -name config | \ - xargs $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config + xargs $(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m $(objtree)/.config $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig # --------------------------------------------------------------------------- diff --git a/arch/arm64/kernel/vdso/Makefile b/arch/arm64/kernel/vdso/Makefile index de981f7b4546..30fe93bb5488 100644 --- a/arch/arm64/kernel/vdso/Makefile +++ b/arch/arm64/kernel/vdso/Makefile @@ -65,7 +65,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE # Generate VDSO offsets using helper script gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh quiet_cmd_vdsosym = VDSOSYM $@ - cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ + cmd_vdsosym = $(NM) $< | $(CONFIG_SHELL) $(gen-vdsosym) | LC_ALL=C sort > $@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE $(call if_changed,vdsosym) diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile index 572475b7b7ed..4f8fe34bc75a 100644 --- a/arch/arm64/kernel/vdso32/Makefile +++ b/arch/arm64/kernel/vdso32/Makefile @@ -205,7 +205,7 @@ quiet_cmd_vdsomunge = MUNGE $@ gen-vdsosym := $(srctree)/$(src)/../vdso/gen_vdso_offsets.sh quiet_cmd_vdsosym = VDSOSYM $@ # The AArch64 nm should be able to read an AArch32 binary - cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ + cmd_vdsosym = $(NM) $< | $(CONFIG_SHELL) $(gen-vdsosym) | LC_ALL=C sort > $@ # Install commands for the unstripped file quiet_cmd_vdso_install = INSTALL32 $@ diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index 2876a7df1b0a..5f6cc3c3da50 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile @@ -28,8 +28,8 @@ cflags-y := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \ -falign-functions=32 -frename-registers -fno-optimize-sibling-calls KBUILD_CFLAGS_KERNEL := -mconstant-gp -GAS_STATUS = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") -KBUILD_CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") +GAS_STATUS = $($(CONFIG_SHELL) $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") +KBUILD_CPPFLAGS += $($(CONFIG_SHELL) $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") ifeq ($(GAS_STATUS),buggy) $(error Sorry, you need a newer version of the assember, one that is built from \ diff --git a/arch/nds32/kernel/vdso/Makefile b/arch/nds32/kernel/vdso/Makefile index 55df25ef0057..e77d4bcfa7c1 100644 --- a/arch/nds32/kernel/vdso/Makefile +++ b/arch/nds32/kernel/vdso/Makefile @@ -39,7 +39,7 @@ $(obj)/%.so: $(obj)/%.so.dbg FORCE # Generate VDSO offsets using helper script gen-vdsosym := $(srctree)/$(src)/gen_vdso_offsets.sh quiet_cmd_vdsosym = VDSOSYM $@ - cmd_vdsosym = $(NM) $< | $(gen-vdsosym) | LC_ALL=C sort > $@ + cmd_vdsosym = $(NM) $< | $(CONFIG_SHELL) $(gen-vdsosym) | LC_ALL=C sort > $@ include/generated/vdso-offsets.h: $(obj)/vdso.so.dbg FORCE $(call if_changed,vdsosym) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a467b9323442..893217ee4a17 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -104,7 +104,7 @@ else ifeq ($(KBUILD_CHECKSRC),2) endif ifneq ($(KBUILD_EXTRA_WARN),) - cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< + cmd_checkdoc = $(PERL) $(srctree)/scripts/kernel-doc -none $< endif # Compile C sources (.c) diff --git a/scripts/Makefile.package b/scripts/Makefile.package index f952fb64789d..4fc16c4776cc 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -44,7 +44,7 @@ if test "$(objtree)" != "$(srctree)"; then \ echo >&2; \ false; \ fi ; \ -$(srctree)/scripts/setlocalversion --save-scmversion; \ +$(CONFIG_SHELL) $(srctree)/scripts/setlocalversion --save-scmversion; \ tar -I $(KGZIP) -c $(RCS_TAR_IGNORE) -f $(2).tar.gz \ --transform 's:^:$(2)/:S' $(TAR_CONTENT) $(3); \ rm -f $(objtree)/.scmversion @@ -123,7 +123,7 @@ git --git-dir=$(srctree)/.git archive --prefix=$(perf-tar)/ \ mkdir -p $(perf-tar); \ git --git-dir=$(srctree)/.git rev-parse HEAD > $(perf-tar)/HEAD; \ (cd $(srctree)/tools/perf; \ -util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \ +$(CONFIG_SHELL) util/PERF-VERSION-GEN $(CURDIR)/$(perf-tar)/); \ tar rf $(perf-tar).tar $(perf-tar)/HEAD $(perf-tar)/PERF-VERSION-FILE; \ rm -r $(perf-tar); \ $(if $(findstring tar-src,$@),, \