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: <20250627100608-9eff2270-8f5b-49d4-9fe3-54a12a14dd25@linutronix.de>
Date: Fri, 27 Jun 2025 10:27:36 +0200
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Benjamin Berg <benjamin@...solutions.net>, 
	Masahiro Yamada <masahiroy@...nel.org>
Cc: Nathan Chancellor <nathan@...nel.org>, 
	Andrew Morton <akpm@...ux-foundation.org>, Willy Tarreau <w@....eu>, 
	Thomas Weißschuh <linux@...ssschuh.net>, Brendan Higgins <brendan.higgins@...ux.dev>, 
	David Gow <davidgow@...gle.com>, Rae Moar <rmoar@...gle.com>, Shuah Khan <shuah@...nel.org>, 
	Jonathan Corbet <corbet@....net>, Nicolas Schier <nicolas.schier@...ux.dev>, 
	Christophe Leroy <christophe.leroy@...roup.eu>, linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-kselftest@...r.kernel.org, kunit-dev@...glegroups.com, linux-doc@...r.kernel.org, 
	workflows@...r.kernel.org, Kees Cook <kees@...nel.org>, 
	Alexander Viro <viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, 
	linux-mm@...ck.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH v4 12/15] kunit: Introduce UAPI testing framework

On Fri, Jun 27, 2025 at 08:58:11AM +0200, Benjamin Berg wrote:
> On Fri, 2025-06-27 at 06:20 +0200, Thomas Weißschuh wrote:
> > On Thu, Jun 26, 2025 at 08:11:17PM +0200, Benjamin Berg wrote:
> > > I ran into two minor issues trying out the patches, see inline.
> > 
> > Thanks for testing the series.
> > 
> > > On Thu, 2025-06-26 at 08:10 +0200, Thomas Weißschuh wrote:
> > > > Enable running UAPI tests as part of kunit.
> > > > The selftests are embedded into the kernel image and their output is
> > > > forwarded to kunit for unified reporting.
> > > > 
> > > > The implementation reuses parts of usermode drivers and usermode
> > > > helpers. However these frameworks are not used directly as they make it
> > > > impossible to retrieve a thread's exit code.
> > > > 
> > > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
> > > > 
> > > > [SNIP]
> > > > +/**
> > > > + * KUNIT_UAPI_EMBED_BLOB() - Embed another build artifact into the kernel
> > > > + * @_name: The name of symbol under which the artifact is embedded.
> > > > + * @_path: Path to the artifact on disk.
> > > > + *
> > > > + * Embeds a build artifact like a userspace executable into the kernel or current module.
> > > > + * The build artifact is read from disk and needs to be already built.
> > > > + */
> > > > +#define KUNIT_UAPI_EMBED_BLOB(_name, _path)					\
> > > > +	asm (									\
> > > > +	"	.pushsection .rodata, \"a\"				\n"	\
> > > > +	"	.global " __stringify(CONCATENATE(_name, _data)) "	\n"	\
> > > > +	__stringify(CONCATENATE(_name, _data)) ":			\n"	\
> > > > +	"	.incbin " __stringify(_path) "				\n"	\
> > > > +	"	.size " __stringify(CONCATENATE(_name, _data)) ", "		\
> > > > +			". - " __stringify(CONCATENATE(_name, _data)) "	\n"	\
> > > > +	"	.global " __stringify(CONCATENATE(_name, _end)) "	\n"	\
> > > > +	__stringify(CONCATENATE(_name, _end)) ":			\n"	\
> > > > +	"	.popsection						\n"	\
> > > > +	);									\
> > > > +										\
> > > > +	extern const char CONCATENATE(_name, _data)[];				\
> > > > +	extern const char CONCATENATE(_name, _end)[];				\
> > > > +										\
> > > > +	static const struct kunit_uapi_blob _name = {				\
> > > > +		.path	= _path,						\
> > > > +		.data	= CONCATENATE(_name, _data),				\
> > > > +		.end	= CONCATENATE(_name, _end),				\
> > > > +	}									\
> > > 
> > > For me, the compiler could not find the files for the ".incbin" unless
> > > I added an include path. i.e. adding
> > >   ccflags-y := -I$(obj)
> > > to lib/kunit/Makefile fixed the problem for me.
> > 
> > Can you share some more details on your build setup?
> > This worked for me as-is and also passed 0day build testing.
> 
> Funny, I ran this on a Fedora 41 with gcc --version saying
> gcc (GCC) 14.3.1 20250523 (Red Hat 14.3.1-1)
> 
> I tried both 32 and 64 bit builds for ARCH=um.
> 
> Attaching my current kernel configuration and the last few lines of a
> V=1 build.
> 
> The kernel I used is a bit newer than what you had. Applied on top of
> ee88bddf7f2f5d1f1da87dd7bedc734048b70e88 (bpf-fixes merge).

So this happens because you are building inside the source tree.
scripts/Makefile.lib has this block:

# $(src) for including checkin headers from generated source files
# $(obj) for including generated headers from checkin source files
ifdef building_out_of_srctree
_c_flags   += $(addprefix -I, $(src) $(obj))
_a_flags   += $(addprefix -I, $(src) $(obj))
_cpp_flags += $(addprefix -I, $(src) $(obj))
endif

Apparently GNU/clang assemblers don't look for .incbin/.include files next to
the including files [0].
In contrast, the ARM compiler does (at least according to its docs) [1].

Maybe we can work around this in the macro, but I assume this will become even
uglier. So for the next revision I'll use your proposal of explicit cflags.
Or if Masahiro prefers to have a more global and generic solution, we can do that.

[0] https://sourceware.org/binutils/docs/as/I.html
[1] https://developer.arm.com/documentation/dui0801/l/Directives-Reference/INCBIN


Thomas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ