summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorBill Wendling <morbo@google.com>2026-09-08 22:27:30 +0000
committerChristian Brauner <brauner@kernel.org>2026-09-09 09:45:01 +0200
commitf6f1a2496ba5dcc076d7fb7aa329887cd6ae55fa (patch)
tree7fc226bb2f249a4f225e06a03782d3d8dfc00475 /include/linux
parentb31397fe3007a9fc636fcc34fcdc2b1e69d46804 (diff)
downloadlinux-next-f6f1a2496ba5dcc076d7fb7aa329887cd6ae55fa.tar.gz
linux-next-f6f1a2496ba5dcc076d7fb7aa329887cd6ae55fa.zip
userns: Add KUnit test suite for uid_gid_map
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. Signed-off-by: Bill Wendling <morbo@google.com> Link: https://patch.msgid.link/20260908222734.3048684-2-morbo@google.com Tested-by: Bradley Morgan <brads@mainlining.org> Reviewed-by: Bradley Morgan <brads@mainlining.org> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/user_namespace.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index 2962256eddf7..633157781edc 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -207,6 +207,12 @@ extern bool in_userns(const struct user_namespace *ancestor,
const struct user_namespace *child);
extern bool current_in_userns(const struct user_namespace *target_ns);
struct ns_common *ns_get_owner(struct ns_common *ns);
+
+#if IS_ENABLED(CONFIG_USER_NS_MAP_KUNIT_TEST)
+extern int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent);
+extern int sort_idmaps(struct uid_gid_map *map);
+#endif /* CONFIG_USER_NS_MAP_KUNIT_TEST */
+
#else
static inline struct user_namespace *get_user_ns(struct user_namespace *ns)