Re: [PATCH] lib: stackinit: Convert to KUnit

Kees Cook
2022-02-25T01:17:10Z

On Thu, Feb 24, 2022 at 11:43:40AM -0800, Daniel Latypov wrote:
> On Wed, Feb 23, 2022 at 9:51 PM Kees Cook <keescook@chromium.org> wrote:
> >
>
> <snip>
>
>
> > /* Userspace headers. */
> > +#define _GNU_SOURCE
> > #include <stdio.h>
> > #include <stdint.h>
> > +#include <stdlib.h>
> > #include <string.h>
> > #include <stdbool.h>
> > #include <errno.h>
> > #include <sys/types.h>
> >
> > /* Linux kernel-ism stubs for stand-alone userspace build. */
>
> This is neat and esp. so that it works.
> But may I ask, what's the value of using this vs UML?

Mainly it's been for giving a single stand-alone file for testing to
compiler devs, packagers, and distro maintainers instead of asking them
to pull down the entire kernel, etc, etc. :)

> Given this has changed into mainly just a KUnit-compatibility layer,
> it feels like it can maybe live as a standalone file, if there's ever
> interest in doing this for other tests.

That's a terrifying and lovely idea!

> It feels like something that will never quite be "supported", but I
> find it neat enough I'd have fun sending some patches to make it more
> realistic.

Right, and as you found, I took some short-cuts that were specific to
how this code used KUnit. :P

I'll ponder this and go through your other suggestions. Thanks!

-Kees

--
Kees Cook