[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 6 Jun 2017 14:03:19 -0500
From: "Eric W. Biederman" <ebiederm@...ssion.com>
To: linux-kernel@...r.kernel.org
Cc: linux-api@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Oleg Nesterov <oleg@...hat.com>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Kees Cook <keescook@...omium.org>,
Roland McGrath <roland@...k.frob.com>,
Al Viro <viro@...IV.linux.org.uk>,
David Howells <dhowells@...hat.com>,
"Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>
Subject: [PATCH 07/26] pidns: Improve the error handling in alloc_pid
Cause any failure to allocate pid 1 to permanently disable pid
allocations for the pid namespace.
Before the pid becomes pid 1 there ns->last_pid and other state
remains unchanged so it is safe to try again...
Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
---
kernel/pid.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/pid.c b/kernel/pid.c
index fd1cde1e4576..f4fb1a84109b 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -321,10 +321,8 @@ struct pid *alloc_pid(struct pid_namespace *ns)
}
if (unlikely(is_child_reaper(pid))) {
- if (pid_ns_prepare_proc(ns)) {
- disable_pid_allocation(ns);
+ if (pid_ns_prepare_proc(ns))
goto out_free;
- }
}
get_pid_ns(ns);
@@ -350,6 +348,10 @@ struct pid *alloc_pid(struct pid_namespace *ns)
put_pid_ns(ns);
out_free:
+ /* Ensure everything stops if allocation of pid 1 failed */
+ if ((i < ns->level) && (pid->numbers[ns->level].nr == 1))
+ disable_pid_allocation(ns);
+
while (++i <= ns->level)
free_pidmap(pid->numbers + i);
--
2.10.1
Powered by blists - more mailing lists