lkml.org 
[lkml]   [2017]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
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@xmission.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
\
 
 \ /
  Last update: 2017-06-12 00:53    [W:0.135 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site