All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kernel/time: Add max_time_namespaces ucount
@ 2020-04-06 17:13 Dmitry Safonov
  2020-04-07  3:31 ` Andrei Vagin
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Safonov @ 2020-04-06 17:13 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dmitry Safonov, Dmitry Safonov, Michael Kerrisk (man-pages),
	Adrian Reber, Andrey Vagin, Christian Brauner, Eric W. Biederman,
	Ingo Molnar, Thomas Gleixner, Vincenzo Frascino, Containers,
	Linux API, stable

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 <adrian@lisas.de>
Cc: Andrey Vagin <avagin@openvz.org>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Containers <containers@lists.linux-foundation.org>
Cc: Linux API <linux-api@vger.kernel.org>
Cc: stable@kernel.org # v5.6+
Reported-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 Documentation/admin-guide/sysctl/user.rst | 6 ++++++
 kernel/ucount.c                           | 1 +
 2 files changed, 7 insertions(+)

diff --git a/Documentation/admin-guide/sysctl/user.rst b/Documentation/admin-guide/sysctl/user.rst
index 650eaa03f15e..c45824589339 100644
--- a/Documentation/admin-guide/sysctl/user.rst
+++ b/Documentation/admin-guide/sysctl/user.rst
@@ -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
 ===================
 
diff --git a/kernel/ucount.c b/kernel/ucount.c
index a53cc2b4179c..29c60eb4ec9b 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -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"),
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel/time: Add max_time_namespaces ucount
  2020-04-06 17:13 [PATCH] kernel/time: Add max_time_namespaces ucount Dmitry Safonov
@ 2020-04-07  3:31 ` Andrei Vagin
  2020-04-07  8:22   ` Michael Kerrisk (man-pages)
  2020-04-07 10:41 ` [tip: timers/urgent] time/namespace: " tip-bot2 for Dmitry Safonov
  2020-04-07 10:43 ` [PATCH] kernel/time: " Christian Brauner
  2 siblings, 1 reply; 6+ messages in thread
From: Andrei Vagin @ 2020-04-07  3:31 UTC (permalink / raw)
  To: Dmitry Safonov via Containers
  Cc: linux-kernel, Eric W. Biederman, Andrey Vagin, Dmitry Safonov,
	Linux API, Dmitry Safonov, stable, Ingo Molnar,
	Michael Kerrisk (man-pages),
	Christian Brauner, Vincenzo Frascino, Thomas Gleixner,
	Adrian Reber

On Mon, Apr 06, 2020 at 06:13:42PM +0100, Dmitry Safonov via Containers wrote:
> 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 <adrian@lisas.de>
> Cc: Andrey Vagin <avagin@openvz.org>
> Cc: Christian Brauner <christian.brauner@ubuntu.com>
> Cc: Eric W. Biederman <ebiederm@xmission.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: Containers <containers@lists.linux-foundation.org>
> Cc: Linux API <linux-api@vger.kernel.org>
> Cc: stable@kernel.org # v5.6+
> Reported-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>

Acked-by: Andrei Vagin <avagin@gmail.com>

> Signed-off-by: Dmitry Safonov <dima@arista.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel/time: Add max_time_namespaces ucount
  2020-04-07  3:31 ` Andrei Vagin
@ 2020-04-07  8:22   ` Michael Kerrisk (man-pages)
  2020-04-07  9:16     ` Vincenzo Frascino
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-07  8:22 UTC (permalink / raw)
  To: Andrei Vagin
  Cc: Dmitry Safonov via Containers, lkml, Eric W. Biederman,
	Andrey Vagin, Dmitry Safonov, Linux API, Dmitry Safonov, stable,
	Ingo Molnar, Christian Brauner, Vincenzo Frascino,
	Thomas Gleixner, Adrian Reber

On Tue, 7 Apr 2020 at 05:31, Andrei Vagin <avagin@gmail.com> wrote:
>
> On Mon, Apr 06, 2020 at 06:13:42PM +0100, Dmitry Safonov via Containers wrote:
> > 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 <adrian@lisas.de>
> > Cc: Andrey Vagin <avagin@openvz.org>
> > Cc: Christian Brauner <christian.brauner@ubuntu.com>
> > Cc: Eric W. Biederman <ebiederm@xmission.com>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> > Cc: Containers <containers@lists.linux-foundation.org>
> > Cc: Linux API <linux-api@vger.kernel.org>
> > Cc: stable@kernel.org # v5.6+
> > Reported-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
>
> Acked-by: Andrei Vagin <avagin@gmail.com>

Acked-by: Michael Kerrisk <mtk.manpages@gmail.com>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel/time: Add max_time_namespaces ucount
  2020-04-07  8:22   ` Michael Kerrisk (man-pages)
@ 2020-04-07  9:16     ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2020-04-07  9:16 UTC (permalink / raw)
  To: mtk.manpages, Andrei Vagin
  Cc: Dmitry Safonov via Containers, lkml, Eric W. Biederman,
	Andrey Vagin, Dmitry Safonov, Linux API, Dmitry Safonov, stable,
	Ingo Molnar, Christian Brauner, Thomas Gleixner, Adrian Reber

On 4/7/20 9:22 AM, Michael Kerrisk (man-pages) wrote:
> On Tue, 7 Apr 2020 at 05:31, Andrei Vagin <avagin@gmail.com> wrote:
>>
>> On Mon, Apr 06, 2020 at 06:13:42PM +0100, Dmitry Safonov via Containers wrote:
>>> 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 <adrian@lisas.de>
>>> Cc: Andrey Vagin <avagin@openvz.org>
>>> Cc: Christian Brauner <christian.brauner@ubuntu.com>
>>> Cc: Eric W. Biederman <ebiederm@xmission.com>
>>> Cc: Ingo Molnar <mingo@redhat.com>
>>> Cc: Thomas Gleixner <tglx@linutronix.de>
>>> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
>>> Cc: Containers <containers@lists.linux-foundation.org>
>>> Cc: Linux API <linux-api@vger.kernel.org>
>>> Cc: stable@kernel.org # v5.6+
>>> Reported-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
>>
>> Acked-by: Andrei Vagin <avagin@gmail.com>
> 
> Acked-by: Michael Kerrisk <mtk.manpages@gmail.com>
> 
> 
> 

Acked-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: timers/urgent] time/namespace: Add max_time_namespaces ucount
  2020-04-06 17:13 [PATCH] kernel/time: Add max_time_namespaces ucount Dmitry Safonov
  2020-04-07  3:31 ` Andrei Vagin
@ 2020-04-07 10:41 ` tip-bot2 for Dmitry Safonov
  2020-04-07 10:43 ` [PATCH] kernel/time: " Christian Brauner
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Dmitry Safonov @ 2020-04-07 10:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Michael Kerrisk (man-pages),
	Dmitry Safonov, Thomas Gleixner, Andrei Vagin, Vincenzo Frascino,
	stable, x86, LKML

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 <dima@arista.com>
AuthorDate:    Mon, 06 Apr 2020 18:13:42 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
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.

Fixes: 769071ac9f20 ("ns: Introduce Time Namespace")
Reported-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Signed-off-by: Dmitry Safonov <dima@arista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Andrei Vagin <avagin@gmail.com>
Acked-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: stable@kernel.org
Link: https://lkml.kernel.org/r/20200406171342.128733-1-dima@arista.com

---
 Documentation/admin-guide/sysctl/user.rst | 6 ++++++
 kernel/ucount.c                           | 1 +
 2 files changed, 7 insertions(+)

diff --git a/Documentation/admin-guide/sysctl/user.rst b/Documentation/admin-guide/sysctl/user.rst
index 650eaa0..c458245 100644
--- a/Documentation/admin-guide/sysctl/user.rst
+++ b/Documentation/admin-guide/sysctl/user.rst
@@ -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
 ===================
 
diff --git a/kernel/ucount.c b/kernel/ucount.c
index a53cc2b..29c60eb 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -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"),

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] kernel/time: Add max_time_namespaces ucount
  2020-04-06 17:13 [PATCH] kernel/time: Add max_time_namespaces ucount Dmitry Safonov
  2020-04-07  3:31 ` Andrei Vagin
  2020-04-07 10:41 ` [tip: timers/urgent] time/namespace: " tip-bot2 for Dmitry Safonov
@ 2020-04-07 10:43 ` Christian Brauner
  2 siblings, 0 replies; 6+ messages in thread
From: Christian Brauner @ 2020-04-07 10:43 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kernel, Eric W. Biederman, Andrey Vagin, Linux API,
	Containers, Dmitry Safonov, stable, Ingo Molnar,
	Michael Kerrisk (man-pages),
	Vincenzo Frascino, Thomas Gleixner, Adrian Reber

On Mon, Apr 06, 2020 at 06:13:42PM +0100, Dmitry Safonov via Containers wrote:
> 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 <adrian@lisas.de>
> Cc: Andrey Vagin <avagin@openvz.org>
> Cc: Christian Brauner <christian.brauner@ubuntu.com>
> Cc: Eric W. Biederman <ebiederm@xmission.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: Containers <containers@lists.linux-foundation.org>
> Cc: Linux API <linux-api@vger.kernel.org>
> Cc: stable@kernel.org # v5.6+
> Reported-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
> Signed-off-by: Dmitry Safonov <dima@arista.com>

Acked-by: Christian Brauner <christian.brauner@ubuntu.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-07 10:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 17:13 [PATCH] kernel/time: Add max_time_namespaces ucount Dmitry Safonov
2020-04-07  3:31 ` Andrei Vagin
2020-04-07  8:22   ` Michael Kerrisk (man-pages)
2020-04-07  9:16     ` Vincenzo Frascino
2020-04-07 10:41 ` [tip: timers/urgent] time/namespace: " tip-bot2 for Dmitry Safonov
2020-04-07 10:43 ` [PATCH] kernel/time: " Christian Brauner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.