Skip to contentSkip to conversation

ucount: Make sure ucounts in /proc/sys/user don't regress again

PATCH Applied Jan Kara 3 participants 3 messages Apr 7, 2020

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 ucount: Make sure ucounts in /proc/sys/user don't regress again

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(). This problem got fixed in commit eeec26d5da82 "time/namespace: Add max_time_namespaces ucount". Add BUILD_BUG_ON to catch a similar problem in the future.

---
 kernel/ucount.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/ucount.c +2 -0
index a53cc2b4179c..3da4d868e452 100644
@@ -81,6 +81,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
Acked-by on v1 1/1
#1 lore raw
Quoted 9 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(). This problem got fixed in commit eeec26d5da82 "time/namespace: Add max_time_namespaces ucount". Add BUILD_BUG_ON to catch a similar problem in the future.

Quoted 21 lines
---
 kernel/ucount.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/ucount.c +2 -1
index a53cc2b4179c..3da4d868e452 100644
@@ -81,6 +81,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) {
--

2.16.4

merge bot Applied
#2 lore raw
In reply to Jan Kara
The following commit has been merged into the timers/urgent branch of tip:

The following commit has been merged into the timers/urgent branch of tip:

Commit-ID:     0f538e3e712a517bd351607de50cd298102c7c08
Gitweb:        https://git.kernel.org/tip/0f538e3e712a517bd351607de50cd298102c7c08
Author:        Jan Kara <[email protected]>
AuthorDate:    Tue, 07 Apr 2020 17:46:43 +02:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 07 Apr 2020 21:51:27 +02:00

ucount: Make sure ucounts in /proc/sys/user don't regress again

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(). This problem got fixed in commit eeec26d5da82 "time/namespace: Add max_time_namespaces ucount".

Add BUILD_BUG_ON to catch a similar problem in the future.

---
 kernel/ucount.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/ucount.c +2 -0
index 29c60eb..11b1596 100644
@@ -82,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) {