Skip to content

Commit 3208450

Browse files
ebiedermtorvalds
authored andcommitted
pidns: use task_active_pid_ns in do_notify_parent
Using task_active_pid_ns is more robust because it works even after we have called exit_namespaces. This change allows us to have parent processes that are zombies. Normally a zombie parent processes is crazy and the last thing you would want to have but in the case of not letting the init process of a pid namespace be reaped until all of it's children are dead and reaped a zombie parent process is exactly what we want. Signed-off-by: Eric W. Biederman <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Pavel Emelyanov <[email protected]> Cc: Cyrill Gorcunov <[email protected]> Cc: Louis Rilling <[email protected]> Cc: Mike Galbraith <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9eaa3d9 commit 3208450

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

kernel/signal.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,19 +1656,18 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
16561656
info.si_signo = sig;
16571657
info.si_errno = 0;
16581658
/*
1659-
* we are under tasklist_lock here so our parent is tied to
1660-
* us and cannot exit and release its namespace.
1659+
* We are under tasklist_lock here so our parent is tied to
1660+
* us and cannot change.
16611661
*
1662-
* the only it can is to switch its nsproxy with sys_unshare,
1663-
* bu uncharing pid namespaces is not allowed, so we'll always
1664-
* see relevant namespace
1662+
* task_active_pid_ns will always return the same pid namespace
1663+
* until a task passes through release_task.
16651664
*
16661665
* write_lock() currently calls preempt_disable() which is the
16671666
* same as rcu_read_lock(), but according to Oleg, this is not
16681667
* correct to rely on this
16691668
*/
16701669
rcu_read_lock();
1671-
info.si_pid = task_pid_nr_ns(tsk, tsk->parent->nsproxy->pid_ns);
1670+
info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(tsk->parent));
16721671
info.si_uid = from_kuid_munged(task_cred_xxx(tsk->parent, user_ns),
16731672
task_uid(tsk));
16741673
rcu_read_unlock();

0 commit comments

Comments
 (0)