Re: [PATCH 2/2] userns: Add KUnit test suite for uid_gid_map
From: Bradley Morgan
Date: Sun Aug 23 2026 - 09:49:10 EST
Hi Bill,
> +config USER_NAMESPACE_KUNIT_TEST
> + tristate "KUnit test for user namespace map insertion" if !KUNIT_ALL_TESTS
> + depends on USER_NS && KUNIT
The test is #include'd into user_namespace.c, which is builtin (USER_NS
is a bool), so =m here still compiles the suite into vmlinux. With
KUNIT=m that calls kunit symbols that live in a module, and the link
fails. Make it bool and depend on KUNIT=y, like EXEC_KUNIT_TEST:
bool "KUnit test for user namespace map insertion" if !KUNIT_ALL_TESTS
depends on USER_NS && KUNIT=y
> + /* Verify sorting is correct */
> + for (i = 0; i < map.nr_extents; i++) {
> + KUNIT_EXPECT_EQ(test, map.forward[i].count, 5);
> + KUNIT_EXPECT_EQ(test, map.reverse[i].count, 5);
> + }
This doesn't verify any sorting. Every extent was inserted with count
5, so the loop passes even if sort_idmaps() did nothing. Either assert
that forward is ordered by .first and reverse by .lower_first, or drop
the sorting claim from the changelog.
> + /* Clean up allocations to avoid leaks */
> + kfree(map.forward);
> + kfree(map.reverse);
Nice.
No tag, add me into V2, please?
Thanks!