lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b1599775-a061-6c91-03a4-c82734c7f58c@digikod.net>
Date:   Fri, 8 Oct 2021 12:21:12 +0200
From:   Mickaël Salaün <mic@...ikod.net>
To:     Kees Cook <keescook@...omium.org>
Cc:     Al Viro <viro@...iv.linux.org.uk>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Aleksa Sarai <cyphar@...har.com>,
        Andy Lutomirski <luto@...nel.org>,
        Arnd Bergmann <arnd@...db.de>,
        Casey Schaufler <casey@...aufler-ca.com>,
        Christian Brauner <christian.brauner@...ntu.com>,
        Christian Heimes <christian@...hon.org>,
        Deven Bowers <deven.desai@...ux.microsoft.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Eric Biggers <ebiggers@...nel.org>,
        Eric Chiang <ericchiang@...gle.com>,
        Florian Weimer <fweimer@...hat.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        James Morris <jmorris@...ei.org>, Jan Kara <jack@...e.cz>,
        Jann Horn <jannh@...gle.com>, Jonathan Corbet <corbet@....net>,
        Lakshmi Ramasubramanian <nramas@...ux.microsoft.com>,
        "Madhavan T . Venkataraman" <madvenka@...ux.microsoft.com>,
        Matthew Garrett <mjg59@...gle.com>,
        Matthew Wilcox <willy@...radead.org>,
        Miklos Szeredi <mszeredi@...hat.com>,
        Mimi Zohar <zohar@...ux.ibm.com>,
        Paul Moore <paul@...l-moore.com>,
        Philippe Trébuchet 
        <philippe.trebuchet@....gouv.fr>,
        Scott Shell <scottsh@...rosoft.com>,
        Shuah Khan <shuah@...nel.org>,
        Steve Dower <steve.dower@...hon.org>,
        Steve Grubb <sgrubb@...hat.com>,
        Thibaut Sautereau <thibaut.sautereau@....gouv.fr>,
        Vincent Strubel <vincent.strubel@....gouv.fr>,
        kernel-hardening@...ts.openwall.com, linux-api@...r.kernel.org,
        linux-fsdevel@...r.kernel.org, linux-integrity@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        linux-security-module@...r.kernel.org,
        Mickaël Salaün <mic@...ux.microsoft.com>
Subject: Re: [PATCH v13 3/3] selftest/interpreter: Add tests for
 trusted_for(2) policies


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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ