Re: [PATCH 2/3] lib/tests: Add randstruct KUnit test
From: Kees Cook
Date: Wed Apr 30 2025 - 14:56:24 EST
On Tue, Apr 29, 2025 at 03:44:01PM +0800, David Gow wrote:
> On Sun, 27 Apr 2025 at 09:38, Kees Cook <kees@xxxxxxxxxx> wrote:
> >
> > Perform basic validation about layout randomization and initialization
> > tracking when using CONFIG_RANDSTRUCT=y. Tested using:
> >
> > $ ./tools/testing/kunit/kunit.py run \
> > --kconfig_add CONFIG_RANDSTRUCT_FULL=y \
> > randstruct
> > [17:22:30] ================= randstruct (2 subtests) ==================
> > [17:22:30] [PASSED] randstruct_layout
> > [17:22:30] [PASSED] randstruct_initializers
> > [17:22:30] =================== [PASSED] randstruct ====================
> > [17:22:30] ============================================================
> > [17:22:30] Testing complete. Ran 2 tests: passed: 2
> > [17:22:30] Elapsed time: 5.091s total, 0.001s configuring, 4.974s building, 0.086s running
> >
> > Adding "--make_option LLVM=1" can be used to test Clang, which also
> > passes.
> >
> > Signed-off-by: Kees Cook <kees@xxxxxxxxxx>
> > ---
>
> This works here for me. I'm a little wary of the prospect of the
> "unlucky or broken" message making the test fail if we're just
> unlucky, but it seems unlikely enough that we can deal with it later
> if it ever becomes a problem.
>
> Acked-by: David Gow <davidgow@xxxxxxxxxx>
Thanks!
Yeah, I wonder if it might be an interesting adjustment to the shuffling
to make sure it isn't a no-op? Like, it would shuffle with the original
hash, and if it's a no-op, it could permute the hash again, and then try
again? Hmmm...
--
Kees Cook