linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: "Al Viro" <viro@zeniv.linux.org.uk>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Aleksa Sarai" <cyphar@cyphar.com>,
	"Andy Lutomirski" <luto@kernel.org>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Casey Schaufler" <casey@schaufler-ca.com>,
	"Christian Brauner" <christian.brauner@ubuntu.com>,
	"Christian Heimes" <christian@python.org>,
	"Deven Bowers" <deven.desai@linux.microsoft.com>,
	"Dmitry Vyukov" <dvyukov@google.com>,
	"Eric Biggers" <ebiggers@kernel.org>,
	"Eric Chiang" <ericchiang@google.com>,
	"Florian Weimer" <fweimer@redhat.com>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"James Morris" <jmorris@namei.org>, "Jan Kara" <jack@suse.cz>,
	"Jann Horn" <jannh@google.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Lakshmi Ramasubramanian" <nramas@linux.microsoft.com>,
	"Madhavan T . Venkataraman" <madvenka@linux.microsoft.com>,
	"Matthew Garrett" <mjg59@google.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Miklos Szeredi" <mszeredi@redhat.com>,
	"Mimi Zohar" <zohar@linux.ibm.com>,
	"Paul Moore" <paul@paul-moore.com>,
	"Philippe Trébuchet" <philippe.trebuchet@ssi.gouv.fr>,
	"Scott Shell" <scottsh@microsoft.com>,
	"Shuah Khan" <shuah@kernel.org>,
	"Steve Dower" <steve.dower@python.org>,
	"Steve Grubb" <sgrubb@redhat.com>,
	"Thibaut Sautereau" <thibaut.sautereau@ssi.gouv.fr>,
	"Vincent Strubel" <vincent.strubel@ssi.gouv.fr>,
	kernel-hardening@lists.openwall.com, linux-api@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	"Mickaël Salaün" <mic@linux.microsoft.com>
Subject: Re: [PATCH v13 3/3] selftest/interpreter: Add tests for trusted_for(2) policies
Date: Fri, 8 Oct 2021 15:44:20 -0700	[thread overview]
Message-ID: <202110081543.1B6BF22@keescook> (raw)
In-Reply-To: <b1599775-a061-6c91-03a4-c82734c7f58c@digikod.net>

On Fri, Oct 08, 2021 at 12:21:12PM +0200, Mickaël Salaün wrote:
> 
> On 07/10/2021 21:48, Kees Cook wrote:
> > On Thu, Oct 07, 2021 at 08:23:20PM +0200, Mickaël Salaün wrote:
> 
> [...]
> 
> >> diff --git a/tools/testing/selftests/interpreter/Makefile b/tools/testing/selftests/interpreter/Makefile
> >> new file mode 100644
> >> index 000000000000..1f71a161d40b
> >> --- /dev/null
> >> +++ b/tools/testing/selftests/interpreter/Makefile
> >> @@ -0,0 +1,21 @@
> >> +# SPDX-License-Identifier: GPL-2.0
> >> +
> >> +CFLAGS += -Wall -O2
> >> +LDLIBS += -lcap
> >> +
> >> +src_test := $(wildcard *_test.c)
> >> +TEST_GEN_PROGS := $(src_test:.c=)
> >> +
> >> +KSFT_KHDR_INSTALL := 1
> >> +include ../lib.mk
> >> +
> >> +khdr_dir = $(top_srcdir)/usr/include
> >> +
> >> +$(khdr_dir)/asm-generic/unistd.h: khdr
> >> +	@:
> >> +
> >> +$(khdr_dir)/linux/trusted-for.h: khdr
> >> +	@:
> >> +
> >> +$(OUTPUT)/%_test: %_test.c $(khdr_dir)/asm-generic/unistd.h $(khdr_dir)/linux/trusted-for.h ../kselftest_harness.h
> >> +	$(LINK.c) $< $(LDLIBS) -o $@ -I$(khdr_dir)
> > 
> > Is all this really needed?
> 
> Yes, all this is needed to be sure that the tests will be rebuild when a
> dependency change (either one of the header files or a source file).
> 
> > 
> > - CFLAGS and LDLIBS will be used by the default rules
> 
> Yes, but it will only run the build command when a source file change,
> not a header file.
> 
> > - khdr is already a pre-dependency when KSFT_KHDR_INSTALL is set
> 
> Yes, but it is not enough to rebuild the tests (and check the installed
> files) when a header file change.
> 
> > - kselftest_harness.h is already a build-dep (see LOCAL_HDRS)
> 
> Yes, but without an explicit requirement, changing kselftest_harness.h
> doesn't force a rebuild.
> 
> > - TEST_GEN_PROGS's .c files are already build-deps
> 
> It is not enough to trigger test rebuilds.
> 
> > 
> > kselftest does, oddly, lack a common -I when KSFT_KHDR_INSTALL is set
> > (which likely should get fixed, though separately from here).
> > 
> > I think you just want:
> > 
> > 
> > src_test := $(wildcard *_test.c)
> > TEST_GEN_PROGS := $(src_test:.c=)
> > 
> > KSFT_KHDR_INSTALL := 1
> > include ../lib.mk
> > 
> > CFLAGS += -Wall -O2 -I$(BUILD)/usr/include
> > LDLIBS += -lcap
> > 
> > $(OUTPUT)/%_test: $(BUILD)/usr/include/linux/trusted-for.h
> > 
> > 
> > (untested)
> > 
> Yep, I re-checked and my Makefile is correct. I didn't find a way to
> make it lighter while correctly handling dependencies.
> I'll just move the -I to CFLAGS.

Okay, thanks for double-checking these. I'll try to fix up kselftests to
DTRT here.

-- 
Kees Cook

      reply	other threads:[~2021-10-08 22:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 18:23 [PATCH v13 0/3] Add trusted_for(2) (was O_MAYEXEC) Mickaël Salaün
2021-10-07 18:23 ` [PATCH v13 1/3] fs: Add trusted_for(2) syscall implementation and related sysctl Mickaël Salaün
2021-10-07 19:25   ` Kees Cook
2021-10-08 10:16     ` Mickaël Salaün
2021-10-07 18:23 ` [PATCH v13 2/3] arch: Wire up trusted_for(2) Mickaël Salaün
2021-10-07 19:26   ` Kees Cook
2021-10-07 18:23 ` [PATCH v13 3/3] selftest/interpreter: Add tests for trusted_for(2) policies Mickaël Salaün
2021-10-07 19:48   ` Kees Cook
2021-10-08 10:21     ` Mickaël Salaün
2021-10-08 22:44       ` Kees Cook [this message]

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=202110081543.1B6BF22@keescook \
    --to=keescook@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=casey@schaufler-ca.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=christian@python.org \
    --cc=corbet@lwn.net \
    --cc=cyphar@cyphar.com \
    --cc=deven.desai@linux.microsoft.com \
    --cc=dvyukov@google.com \
    --cc=ebiggers@kernel.org \
    --cc=ericchiang@google.com \
    --cc=fweimer@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=jack@suse.cz \
    --cc=jannh@google.com \
    --cc=jmorris@namei.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=madvenka@linux.microsoft.com \
    --cc=mic@digikod.net \
    --cc=mic@linux.microsoft.com \
    --cc=mjg59@google.com \
    --cc=mszeredi@redhat.com \
    --cc=nramas@linux.microsoft.com \
    --cc=paul@paul-moore.com \
    --cc=philippe.trebuchet@ssi.gouv.fr \
    --cc=scottsh@microsoft.com \
    --cc=sgrubb@redhat.com \
    --cc=shuah@kernel.org \
    --cc=steve.dower@python.org \
    --cc=thibaut.sautereau@ssi.gouv.fr \
    --cc=vincent.strubel@ssi.gouv.fr \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=zohar@linux.ibm.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).