Skip to content

Commit 751c644

Browse files
committed
pid: Handle the exit of a multi-threaded init.
When a multi-threaded init exits and the initial thread is not the last thread to exit the initial thread hangs around as a zombie until the last thread exits. In that case zap_pid_ns_processes needs to wait until there are only 2 hashed pids in the pid namespace not one. v2. Replace thread_pid_vnr(me) == 1 with the test thread_group_leader(me) as suggested by Oleg. Cc: stable@vger.kernel.org Cc: Oleg Nesterov <oleg@redhat.com> Reported-by: Caj Larsson <caj@omnicloud.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent 92f28d9 commit 751c644

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎kernel/pid_namespace.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
181181
int nr;
182182
int rc;
183183
struct task_struct *task, *me = current;
184+
int init_pids = thread_group_leader(me) ? 1 : 2;
184185

185186
/* Don't allow any more processes into the pid namespace */
186187
disable_pid_allocation(pid_ns);
@@ -230,7 +231,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
230231
*/
231232
for (;;) {
232233
set_current_state(TASK_UNINTERRUPTIBLE);
233-
if (pid_ns->nr_hashed == 1)
234+
if (pid_ns->nr_hashed == init_pids)
234235
break;
235236
schedule();
236237
}

0 commit comments

Comments
 (0)