Skip to contentSkip to conversation

ucount: Fix wrong inotify ucounts in /proc/sys/user

PATCH In review Jan Kara 2 participants 3 messages Apr 7, 2020 Stable branch

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 ucount: Fix wrong inotify ucounts in /proc/sys/user

Commit 769071ac9f20 "ns: Introduce Time Namespace" broke reporting of inotify ucounts (max_inotify_instances, max_inotify_watches) in /proc/sys/user because it has added UCOUNT_TIME_NAMESPACES into enum ucount_type but didn't properly update reporting in kernel/ucount.c:setup_userns_sysctls(). Update the reporting to fix the issue and also add BUILD_BUG_ON to catch a similar problem in the future.

Fixes 769071ac9f20 "ns: Introduce Time Namespace"
---
 kernel/ucount.c | 3 +++
 1 file changed, 3 insertions(+)
kernel/ucount.c +3 -0
index a53cc2b4179c..11b1596e2542 100644
@@ -69,6 +69,7 @@ static struct ctl_table user_table[] = {
 	UCOUNT_ENTRY("max_net_namespaces"),
 	UCOUNT_ENTRY("max_mnt_namespaces"),
 	UCOUNT_ENTRY("max_cgroup_namespaces"),
+	UCOUNT_ENTRY("max_time_namespaces"),
 #ifdef CONFIG_INOTIFY_USER
 	UCOUNT_ENTRY("max_inotify_instances"),
 	UCOUNT_ENTRY("max_inotify_watches"),
@@ -81,6 +82,8 @@ bool setup_userns_sysctls(struct user_namespace *ns)
 {
 #ifdef CONFIG_SYSCTL
 	struct ctl_table *tbl;
+
+	BUILD_BUG_ON(ARRAY_SIZE(user_table) != UCOUNT_COUNTS + 1);
 	setup_sysctl_set(&ns->set, &set_root, set_is_seen);
 	tbl = kmemdup(user_table, sizeof(user_table), GFP_KERNEL);
 	if (tbl) {
Signature · 1 line
2.16.4
#1 lore raw
Quoted 7 lines · Jan Kara

Commit 769071ac9f20 "ns: Introduce Time Namespace" broke reporting of inotify ucounts (max_inotify_instances, max_inotify_watches) in /proc/sys/user because it has added UCOUNT_TIME_NAMESPACES into enum ucount_type but didn't properly update reporting in kernel/ucount.c:setup_userns_sysctls(). Update the reporting to fix the issue and also add BUILD_BUG_ON to catch a similar problem in the future.

Just merged that:

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=timers/urgent&id=eeec26d5da8248ea4e240b8795bb4364213d3247

Could you please send a patch with just the build bug on ?

Thanks,

tglx

author
#2 lore raw
Quoted 9 lines · Thomas Gleixner
Quoted 7 lines · Jan Kara

Commit 769071ac9f20 "ns: Introduce Time Namespace" broke reporting of inotify ucounts (max_inotify_instances, max_inotify_watches) in /proc/sys/user because it has added UCOUNT_TIME_NAMESPACES into enum ucount_type but didn't properly update reporting in kernel/ucount.c:setup_userns_sysctls(). Update the reporting to fix the issue and also add BUILD_BUG_ON to catch a similar problem in the future.

Quoted 5 lines

Just merged that:

https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?h=timers/urgent&id=eeec26d5da8248ea4e240b8795bb4364213d3247

Could you please send a patch with just the build bug on ?

Sure, will do.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR