Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+2 -1
+2 -1
kernel/pid_namespace.c
··· 181 181 int nr; 182 182 int rc; 183 183 struct task_struct *task, *me = current; 184 + int init_pids = thread_group_leader(me) ? 1 : 2; 184 185 185 186 /* Don't allow any more processes into the pid namespace */ 186 187 disable_pid_allocation(pid_ns); ··· 231 230 */ 232 231 for (;;) { 233 232 set_current_state(TASK_UNINTERRUPTIBLE); 234 - if (pid_ns->nr_hashed == 1) 233 + if (pid_ns->nr_hashed == init_pids) 235 234 break; 236 235 schedule(); 237 236 }