From: Shuah Khan <skhan@linuxfoundation.org> To: Kees Cook <keescook@chromium.org> Cc: shuah@kernel.org, luto@amacapital.net, wad@chromium.org, daniel@iogearbox.net, kafai@fb.com, yhs@fb.com, andriin@fb.com, gregkh@linuxfoundation.org, tglx@linutronix.de, khilman@baylibre.com, mpe@ellerman.id.au, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, Shuah Khan <skhan@linuxfoundation.org> Subject: Re: [PATCH v2 2/4] selftests: Fix seccomp to support relocatable build (O=objdir) Date: Thu, 5 Mar 2020 09:41:34 -0700 Message-ID: <f4cf1527-4565-9f08-a8a2-9f51022eac63@linuxfoundation.org> (raw) In-Reply-To: <202003041815.B8C73DEC@keescook> On 3/4/20 7:20 PM, Kees Cook wrote: > On Wed, Mar 04, 2020 at 05:36:27PM -0700, Shuah Khan wrote: >> Fix seccomp relocatable builds. This is a simple fix to use the >> right lib.mk variable TEST_CUSTOM_PROGS to continue to do custom >> build to preserve dependency on kselftest_harness.h local header. >> This change applies cutom rule to seccomp_bpf seccomp_benchmark >> for a simpler logic. >> >> Uses $(OUTPUT) defined in lib.mk to handle build relocation. >> >> The following use-cases work with this change: >> >> In seccomp directory: >> make all and make clean > > This works. > >> >> From top level from main Makefile: >> make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc \ >> CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp > > This fails for me: > > $ make kselftest-install O=objdir ARCH=arm64 HOSTCC=gcc CROSS_COMPILE=aarch64-linux-gnu- TARGETS=seccomp > make[1]: Entering directory '/home/kees/src/linux/objdir' > make --no-builtin-rules INSTALL_HDR_PATH=$BUILD/usr \ > ARCH=arm64 -C ../../.. headers_install > make[4]: ../scripts/Makefile.build: No such file or directory > make[4]: *** No rule to make target '../scripts/Makefile.build'. Stop. > make[3]: *** [Makefile:501: scripts_basic] Error 2 > make[2]: *** [Makefile:151: khdr] Error 2 > make[1]: *** [/home/kees/src/linux/Makefile:1221: kselftest-install] Error 2 > make[1]: Leaving directory '/home/kees/src/linux/objdir' > make: *** [Makefile:180: sub-make] Error 2 > > (My "objdir" is empty) > > If I remove O=objdir everything is fine. And see below... > >> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> >> --- >> tools/testing/selftests/seccomp/Makefile | 19 +++++++++---------- >> 1 file changed, 9 insertions(+), 10 deletions(-) >> >> diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile >> index 1760b3e39730..355bcbc0394a 100644 >> --- a/tools/testing/selftests/seccomp/Makefile >> +++ b/tools/testing/selftests/seccomp/Makefile >> @@ -1,17 +1,16 @@ >> # SPDX-License-Identifier: GPL-2.0 >> -all: >> - >> -include ../lib.mk >> +CFLAGS += -Wl,-no-as-needed -Wall >> +LDFLAGS += -lpthread >> >> .PHONY: all clean >> >> -BINARIES := seccomp_bpf seccomp_benchmark >> -CFLAGS += -Wl,-no-as-needed -Wall >> +include ../lib.mk >> + >> +# OUTPUT set by lib.mk >> +TEST_CUSTOM_PROGS := $(OUTPUT)/seccomp_bpf $(OUTPUT)/seccomp_benchmark >> >> -seccomp_bpf: seccomp_bpf.c ../kselftest_harness.h >> - $(CC) $(CFLAGS) $(LDFLAGS) $< -lpthread -o $@ >> +$(TEST_CUSTOM_PROGS): ../kselftest_harness.h >> >> -TEST_PROGS += $(BINARIES) >> -EXTRA_CLEAN := $(BINARIES) >> +all: $(TEST_CUSTOM_PROGS) >> >> -all: $(BINARIES) >> +EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) >> -- >> 2.20.1 >> > > Instead of the TEST_CUSTOM_PROGS+all dance, you can just add an explicit > dependency, with the final seccomp/Makefile looking like this: > > > # SPDX-License-Identifier: GPL-2.0 > CFLAGS += -Wl,-no-as-needed -Wall > LDFLAGS += -lpthread > > TEST_GEN_PROGS := seccomp_bpf seccomp_benchmark > TEST_CUSTOM_PROGS is for differentiating test programs that can't use lib.mk generic rules. It is appropriate to use for seccomp_bpf > include ../lib.mk > > # Additional dependencies > $(OUTPUT)/seccomp_bpf: ../kselftest_harness.h > > > (Though this fails in the same way as above when run from the top-level > directory.) > I didn't see this because I have been the same directory I used for relocated cross-build kernel. :( Thanks for testing this. I know the problem here. all is a dependency for install step and $(OUTPUT) is referencing the objdir before it gets created. It is a Makefile/lib.mk problem to fix. I will do a separate patch for this. This will show up in any test that is using $(OUTPUT) to relocate objects mainly the ones that require custom build rule like seeccomp. thanks, -- Shuah
next prev parent reply index Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-05 0:36 Shuah Khan 2020-03-05 2:20 ` Kees Cook 2020-03-05 16:41 ` Shuah Khan [this message] 2020-03-05 17:42 ` Kees Cook 2020-03-10 23:11 ` Shuah Khan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=f4cf1527-4565-9f08-a8a2-9f51022eac63@linuxfoundation.org \ --to=skhan@linuxfoundation.org \ --cc=andriin@fb.com \ --cc=bpf@vger.kernel.org \ --cc=daniel@iogearbox.net \ --cc=gregkh@linuxfoundation.org \ --cc=kafai@fb.com \ --cc=keescook@chromium.org \ --cc=khilman@baylibre.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=luto@amacapital.net \ --cc=mpe@ellerman.id.au \ --cc=netdev@vger.kernel.org \ --cc=shuah@kernel.org \ --cc=tglx@linutronix.de \ --cc=wad@chromium.org \ --cc=yhs@fb.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
LKML Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \ linux-kernel@vger.kernel.org public-inbox-index lkml Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git