From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64B91C433E7 for ; Tue, 13 Oct 2020 16:05:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2C9625242 for ; Tue, 13 Oct 2020 16:05:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gNESlgSJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=nifty.com header.i=@nifty.com header.b="j1iFKrZF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2C9625242 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1MltHdRnZEk/Bcnp6VHLZNlCddGZuCsjt1vIFHoz2ak=; b=gNESlgSJ2Z306xGhMv9xXliaf Xu3pcGpwWsMCgHQWF+70wPTPTj+Wx4VqNHWmokBSF21xvjpa+pSuGzYvvP5Ykh/mk6YMw0nXhrypV FS03AVWBrkm81vQe5N7306BwVAuwTivCnA5g0WY4bicWsSkdOj/mFv4LF96y7xMQbLkysCKOXyoOg 7I7g+6afoUQ1FcCVNOJ2BwsqYFdpbWd5LiZH171JsCwEGgwa7NZSqnOs/Xl8zAG9dmh1YX1aapuP7 S50XDrkHx/OikrPhgs6tPAVWFopoeCuIMIdPkuqK54iwbwntQ9l+iM16hCTRyGaLzEhzizL2J8vUV B2vYZ6lsg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSMlp-00079t-4N; Tue, 13 Oct 2020 16:03:25 +0000 Received: from conssluserg-05.nifty.com ([210.131.2.90]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSMlj-000791-1s for linux-arm-kernel@lists.infradead.org; Tue, 13 Oct 2020 16:03:20 +0000 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (authenticated) by conssluserg-05.nifty.com with ESMTP id 09DG2v1A011076 for ; Wed, 14 Oct 2020 01:02:57 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com 09DG2v1A011076 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1602604978; bh=3Doy0JIMW8UlEO9WI984BiymwAAc3PcCowImi1wWrlc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=j1iFKrZFjKmYB3TS8hS72+3ACn6mEqyeXyYK+OY/XcWRDiCLMKufgU6PI75iJ58FZ ZqD5aLNvA39nMpysKLZC72E0xGyW4sUckhjz3n8gIUAl6h4kyMvPLBXh+3D6sKuZgq 9cG4qFz+WchFkOtXJdWjeeCRbIqifjTOC+FLInKWf6g0+tv0J+3G7ht7fzrqeTNEdJ v5kDS0j9pSdICvj5MU3estuPiL7nPx1xsi/cRk22nNIwntgtgS5IxjFK26ZgrzQh0a Bof89zfD3ncfUS3jTnaZbcQF0ztFME3JhZwXAjf5wF7UZGbrVnzEeQPdD9dnPNtU3y pRitjo25wXk9Q== X-Nifty-SrcIP: [209.85.214.177] Received: by mail-pl1-f177.google.com with SMTP id y1so56892plp.6 for ; Tue, 13 Oct 2020 09:02:57 -0700 (PDT) X-Gm-Message-State: AOAM530EflQJVJn1NeZQqzGpkw7JWBCSBKd1QgIrJIGbhQjXE0zJWk8c QcGWj02l6v1flT8zrLv7gwynWelOK8T4DB61EaA= X-Google-Smtp-Source: ABdhPJwppXe7uVVWc+nfoNIz3RPoqqMPJii8V+bgs/KaSKZBm5bodncuyboRoJgCH3YbpjaBw+5sUrG7IlnA22ZMdAo= X-Received: by 2002:a17:902:c3d4:b029:d3:df24:1619 with SMTP id j20-20020a170902c3d4b02900d3df241619mr159914plj.1.1602604976734; Tue, 13 Oct 2020 09:02:56 -0700 (PDT) MIME-Version: 1.0 References: <20201012170631.1241502-1-ujjwalkumar0501@gmail.com> <20201012170631.1241502-3-ujjwalkumar0501@gmail.com> <53b7257e-b192-07da-9dd3-06497ce826f0@petrovitsch.priv.at> In-Reply-To: <53b7257e-b192-07da-9dd3-06497ce826f0@petrovitsch.priv.at> From: Masahiro Yamada Date: Wed, 14 Oct 2020 01:02:19 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] kbuild: use interpreters to invoke scripts To: Bernd Petrovitsch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201013_120319_428177_71C47E29 X-CRM114-Status: GOOD ( 31.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Marek , linux-ia64@vger.kernel.org, Kees Cook , Linux Kbuild mailing list , Nick Desaulniers , Linux Kernel Mailing List , Ujjwal Kumar , clang-built-linux , Lukas Bulwahn , Nathan Chancellor , linux-kernel-mentees@lists.linuxfoundation.org, Andrew Morton , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 13, 2020 at 4:03 AM Bernd Petrovitsch wrote: > > Hi all! > > On 12/10/2020 18:42, Ujjwal Kumar wrote: > > On 12/10/20 11:50 pm, Lukas Bulwahn wrote: > >> > >> > >> On Mon, 12 Oct 2020, Ujjwal Kumar wrote: > >> > >>> 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 > >>> --- > >>> 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 0af7945caa61..df20e71dd7c8 100644 > >>> --- a/Makefile > >>> +++ b/Makefile > >>> @@ -1256,7 +1256,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 > >>> @@ -1312,7 +1312,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 edccdb77c53e..fb07804b7fc1 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 7f96a1a9f68c..617c9ac58156 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 703b1c4f6d12..86d42a2d09cb 100644 > >>> --- a/arch/ia64/Makefile > >>> +++ b/arch/ia64/Makefile > >>> @@ -27,8 +27,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 = $(shell $(CONFIG_SHELL) $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") > >>> +KBUILD_CPPFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)") > >> > >> Here is an instance of what Masahiro-san pointed out being wrong. > >> > >> Ujjwal, will you send a v3? > > > > Following is the quoted text from the reply mail from Masahiro > > > >>> -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)") > >> > >> > >> > >> These changes look wrong to me. > >> > >> $($(CONFIG_SHELL) -> $(shell $(CONFIG_SHELL) > >> > > > > From the above text, I understand as follows: > > Did you actually *test* that (expecially) these lines work > afterwards as good as before? > > > That my proposed change: > > $(shell $(src...) -> $($(CONFIG_SHELL) $(src...) > > > > is WRONG > > Yup, as it's in a Makefile and that's a Makefile construct. > > > and in the next line he suggested the required correction. > > That being: > > $($(CONFIG_SHELL) -> $(shell $(CONFIG_SHELL) > > Such stuff should generally not be needed as the to-be-used > shell can be set in Makefiles via a "SHELL = " assignment > (defaulting to /bin/sh - what else;-). > Flags for the shell can BTW set with ".SHELLFLAGS = ". You are talking about a different thing. Take the current code as an example: $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") Here are two shell invocations. [1] The command $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)" is run in /bin/sh because the default value of SHELL is /bin/sh. [2] The script, arch/ia64/scripts/check-gas, is run in /bin/sh because the hash-bang (the first line of check-gas) specifies #!/bin/sh Bernd is talking about [1]. In contrast, this patch is addressing [2] because Andrew Morton suggested to run scripts without relying on the executable bit. (and, after this patch, we run scripts without relying on the hash-bang because we now specify the interpreter.) Of course, [1] and [2] can be different. I always want to use /bin/sh for [1], so please do not use bash-extension inside $(shell ...) You have more choices for [2]. If arch/ia64/scripts/check-gas had been written with bash-extension, the code would have been changed into: $(shell $(BASH) $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)") I hope this will be clearer. > So please > -) learn basic "Makefile" + "make" before brainlessly patching > a Makefile. > -) actually testy your changes to make sure the patch didn't > broke anything > -) and - last but not least - check if there isn't a shell > already set (and which). > > MfG, > Bernd > -- > There is no cloud, just other people computers. > -- https://static.fsf.org/nosvn/stickers/thereisnocloud.svg -- Best Regards Masahiro Yamada _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel