[PATCH RFC v3 07/90] ucount: count the id blocks a user holds
From: Josef Bacik
Date: Thu Nov 05 2026 - 10:01:49 EST
A block of ids gives access to nothing, so taking one requires no
privilege. But the number of blocks is limited.
Add a ucount, user.max_cell_id_blocks, so that a single user cannot use up
the window.
Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
---
include/linux/user_namespace.h | 3 +++
kernel/ucount.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index 5c8cf31ab9d4..f0b0fe12c2fd 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -61,6 +61,9 @@ enum ucount_type {
#endif
#if IS_ENABLED(CONFIG_BINFMT_MISC)
UCOUNT_BINFMT_MISC_INTERPRETERS,
+#endif
+#ifdef CONFIG_CELLS
+ UCOUNT_CELL_ID_BLOCKS,
#endif
UCOUNT_COUNTS,
};
diff --git a/kernel/ucount.c b/kernel/ucount.c
index 94b70502dc9d..7eab985121f6 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -93,6 +93,9 @@ static const struct ctl_table user_table[] = {
#if IS_ENABLED(CONFIG_BINFMT_MISC)
UCOUNT_ENTRY("max_binfmt_misc_interpreters"),
#endif
+#ifdef CONFIG_CELLS
+ UCOUNT_ENTRY("max_cell_id_blocks"),
+#endif
};
#endif /* CONFIG_SYSCTL */
--
2.55.0