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 <[email protected]>

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,
> +};


-Kees

-- 
Kees Cook

Reply via email to