Skip to contentSkip to conversation

kernel/time: Add max_time_namespaces ucount

PATCH Applied Dmitry Safonov 6 participants 6 messages Apr 6, 2020 – Apr 7, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/time: Add max_time_namespaces ucount

Introduce missing time namespaces limit per-userns. Michael noticed that userns limit for number of time namespaces is missing.

Furthermore, time namespace introduced UCOUNT_TIME_NAMESPACES, but didn't introduce an array member in user_table[]. It would make array's initialisation OOB write, but by luck the user_table array has an excessive empty member (all accesses to the array are limited with UCOUNT_COUNTS - so it silently reuses the last free member.

Fixes user-visible regression: max_inotify_instances by reason of the missing UCOUNT_ENTRY() has limited max number of namespaces instead of the number of inotify instances.

Fixes 769071ac9f20 ("ns: Introduce Time Namespace")
Cc Adrian Reber <[email protected]>
Cc Andrey Vagin <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vincenzo Frascino <[email protected]>
Cc Containers <[email protected]>
Cc Linux API <[email protected]>
---
 Documentation/admin-guide/sysctl/user.rst | 6 ++++++
 kernel/ucount.c                           | 1 +
 2 files changed, 7 insertions(+)
Documentation/admin-guide/sysctl/user.rst +6 -0
index 650eaa03f15e..c45824589339 100644
@@ -65,6 +65,12 @@ max_pid_namespaces
   The maximum number of pid namespaces that any user in the current
   user namespace may create.
 
+max_time_namespaces
+===================
+
+  The maximum number of time namespaces that any user in the current
+  user namespace may create.
+
 max_user_namespaces
 ===================
 
kernel/ucount.c +1 -0
index a53cc2b4179c..29c60eb4ec9b 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"),
Signature · 1 line
2.26.0
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Dmitry Safonov via Containers

Introduce missing time namespaces limit per-userns. Michael noticed that userns limit for number of time namespaces is missing.

Furthermore, time namespace introduced UCOUNT_TIME_NAMESPACES, but didn't introduce an array member in user_table[]. It would make array's initialisation OOB write, but by luck the user_table array has an excessive empty member (all accesses to the array are limited with UCOUNT_COUNTS - so it silently reuses the last free member.

Fixes user-visible regression: max_inotify_instances by reason of the missing UCOUNT_ENTRY() has limited max number of namespaces instead of the number of inotify instances.

Quoted 12 lines
Fixes 769071ac9f20 ("ns: Introduce Time Namespace")
Cc Adrian Reber <[email protected]>
Cc Andrey Vagin <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vincenzo Frascino <[email protected]>
Cc Containers <[email protected]>
Cc Linux API <[email protected]>
Quoted 1 line
#2 lore raw
Quoted 29 lines · Andrei Vagin
Quoted 14 lines · Dmitry Safonov via Containers

Introduce missing time namespaces limit per-userns. Michael noticed that userns limit for number of time namespaces is missing.

Furthermore, time namespace introduced UCOUNT_TIME_NAMESPACES, but didn't introduce an array member in user_table[]. It would make array's initialisation OOB write, but by luck the user_table array has an excessive empty member (all accesses to the array are limited with UCOUNT_COUNTS - so it silently reuses the last free member.

Fixes user-visible regression: max_inotify_instances by reason of the missing UCOUNT_ENTRY() has limited max number of namespaces instead of the number of inotify instances.

Quoted 12 lines
Fixes 769071ac9f20 ("ns: Introduce Time Namespace")
Cc Adrian Reber <[email protected]>
Cc Andrey Vagin <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vincenzo Frascino <[email protected]>
Cc Containers <[email protected]>
Cc Linux API <[email protected]>
Quoted 1 line
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#3 lore raw
Quoted 30 lines · Michael Kerrisk (man-pages)
Quoted 29 lines · Andrei Vagin
Quoted 26 lines · Dmitry Safonov via Containers

Introduce missing time namespaces limit per-userns. Michael noticed that userns limit for number of time namespaces is missing.

Furthermore, time namespace introduced UCOUNT_TIME_NAMESPACES, but didn't introduce an array member in user_table[]. It would make array's initialisation OOB write, but by luck the user_table array has an excessive empty member (all accesses to the array are limited with UCOUNT_COUNTS - so it silently reuses the last free member.

Fixes user-visible regression: max_inotify_instances by reason of the missing UCOUNT_ENTRY() has limited max number of namespaces instead of the number of inotify instances.

Fixes 769071ac9f20 ("ns: Introduce Time Namespace")
Cc Adrian Reber <[email protected]>
Cc Andrey Vagin <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vincenzo Frascino <[email protected]>
Cc Containers <[email protected]>
Cc Linux API <[email protected]>
Quoted 6 lines
Quoted 1 line
Signature · 2 lines
Regards,
Vincenzo
merge bot Applied
#4 lore raw

[tip: timers/urgent] time/namespace: Add max_time_namespaces ucount

In reply to Dmitry Safonov
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:     eeec26d5da8248ea4e240b8795bb4364213d3247
Gitweb:        https://git.kernel.org/tip/eeec26d5da8248ea4e240b8795bb4364213d3247
Author:        Dmitry Safonov <[email protected]>
AuthorDate:    Mon, 06 Apr 2020 18:13:42 +01:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 07 Apr 2020 12:37:21 +02:00

time/namespace: Add max_time_namespaces ucount

Michael noticed that userns limit for number of time namespaces is missing.

Furthermore, time namespace introduced UCOUNT_TIME_NAMESPACES, but didn't introduce an array member in user_table[]. It would make array's initialisation OOB write, but by luck the user_table array has an excessive empty member (all accesses to the array are limited with UCOUNT_COUNTS - so it silently reuses the last free member.

Fixes user-visible regression: max_inotify_instances by reason of the missing UCOUNT_ENTRY() has limited max number of namespaces instead of the number of inotify instances.

---
 Documentation/admin-guide/sysctl/user.rst | 6 ++++++
 kernel/ucount.c                           | 1 +
 2 files changed, 7 insertions(+)
Documentation/admin-guide/sysctl/user.rst +6 -0
index 650eaa0..c458245 100644
@@ -65,6 +65,12 @@ max_pid_namespaces
   The maximum number of pid namespaces that any user in the current
   user namespace may create.
 
+max_time_namespaces
+===================
+
+  The maximum number of time namespaces that any user in the current
+  user namespace may create.
+
 max_user_namespaces
 ===================
 
kernel/ucount.c +1 -0
index a53cc2b..29c60eb 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"),
Acked-by on v1 1/1
#5 lore raw
In reply to Dmitry Safonov
Quoted 14 lines · Dmitry Safonov via Containers

Introduce missing time namespaces limit per-userns. Michael noticed that userns limit for number of time namespaces is missing.

Furthermore, time namespace introduced UCOUNT_TIME_NAMESPACES, but didn't introduce an array member in user_table[]. It would make array's initialisation OOB write, but by luck the user_table array has an excessive empty member (all accesses to the array are limited with UCOUNT_COUNTS - so it silently reuses the last free member.

Fixes user-visible regression: max_inotify_instances by reason of the missing UCOUNT_ENTRY() has limited max number of namespaces instead of the number of inotify instances.

Quoted 13 lines
Fixes 769071ac9f20 ("ns: Introduce Time Namespace")
Cc Adrian Reber <[email protected]>
Cc Andrey Vagin <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Eric W. Biederman <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vincenzo Frascino <[email protected]>
Cc Containers <[email protected]>
Cc Linux API <[email protected]>