Re: [PATCH v4 2/2] userns: Add KUnit test suite for uid_gid_map
From: Bill Wendling
Date: Tue Sep 08 2026 - 13:50:35 EST
On Fri, Sep 4, 2026 at 4:41 PM Kees Cook <kees@xxxxxxxxxx> wrote:
> On Wed, Aug 26, 2026 at 10:00:35PM +0000, Bill Wendling wrote:
> > Add a KUnit test suite to verify the insertion and sorting of mappings
> > in struct uid_gid_map. This test suite validates both base extent
> > insertion (<= 5 mappings) and extended extent insertion (> 5 mappings,
> > which triggers the allocation of the forward and reverse pointers).
> >
> > This is especially useful for verifying that the __counted_by_ptr
> > attribute added to 'forward' and 'reverse' pointers works correctly
> > without causing any runtime bounds-checking panics or traps.
> >
> > Assisted-by: Gemini:3.1-pro-preview
> > Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
>
> Various style nit-picks as dictated by
> Documentation/dev-tools/kunit/style.rst
>
> (We may need to teach Sashiko about KUnit style?)
>
> > kernel/user_namespace_kunit.c | 92 +++++++++++++++++++++++++++++++++++
>
> Like below's naming, this should be named after the suite, and in the
> tests/ subdir (even when #included), so it should be:
> kernel/tests/user_ns_map_kunit.c
>
> > +config USER_NAMESPACE_KUNIT_TEST
>
> The suite and Kconfig should match, so this should be
> USER_NS_MAP_KUNIT_TEST
>
> > + bool "Test user namespace map insertion" if !KUNIT_ALL_TESTS
> > + depends on KUNIT=y
> > + default KUNIT_ALL_TESTS
>
> I think you need a "depends on USER_NS" ?
>
> > +static struct kunit_suite user_ns_map_test_suite = {
> > + .name = "user_ns_map",
> > + .test_cases = user_ns_map_test_cases,
> > +};
>
>
"Roger that" for all of the above. I was waiting for more comments
before proceeding, but I think I'll send out the "visibility.h"
version, with the above fixes, so that we have something concrete to
discuss.
-bw