Thread (33 messages) 33 messages, 5 authors, 2017-06-07
STALE3276d

[PATCH 07/26] pidns: Improve the error handling in alloc_pid

From: Eric W. Biederman <hidden>
Date: 2017-06-06 19:12:17
Also in: lkml
Subsystem: the rest · Maintainer: Linus Torvalds

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" <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help