aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/pid_namespace.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-09-02 17:35:48 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-09-02 22:21:38 -0400
commitadd0d4dfd660e9e4fd0af3eac3cad23583c9558f (patch)
tree8bba7c39efcd5999c0925bed083a0ca68d6a5e40 /kernel/pid_namespace.c
parente385ea63f44b475e034a78b6d8bc6bb50caf72ca (diff)
pid_ns: zap_pid_ns_processes: fix the ->child_reaper changing
zap_pid_ns_processes() sets pid_ns->child_reaper = NULL, this is wrong. Yes, we have already killed all tasks in this namespace, and sys_wait4() doesn't see any child. But this doesn't mean ->children list is empty, we may have EXIT_DEAD tasks which are not visible to do_wait(). In that case the subsequent forget_original_parent() will crash the kernel because it will try to re-parent these tasks to the NULL reaper. Even if there are no childs, it is not good that forget_original_parent() uses reaper == NULL. Change the code to set ->child_reaper = init_pid_ns.child_reaper instead. We could use pid_ns->parent->child_reaper as well, I think this does not really matter. These EXIT_DEAD tasks are not visible to the new ->parent after re-parenting, they will silently do release_task() eventually. Note that we must change ->child_reaper, otherwise forget_original_parent() will use reaper == father, and in that case we will hit the (correct) BUG_ON(!list_empty(&father->children)). Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Acked-by: Serge Hallyn <serue@us.ibm.com> Acked-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com> Acked-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/pid_namespace.c')
-rw-r--r--kernel/pid_namespace.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index ea567b78d1aa..598f1eec9826 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -179,9 +179,12 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
179 rc = sys_wait4(-1, NULL, __WALL, NULL); 179 rc = sys_wait4(-1, NULL, __WALL, NULL);
180 } while (rc != -ECHILD); 180 } while (rc != -ECHILD);
181 181
182 182 /*
183 /* Child reaper for the pid namespace is going away */ 183 * We can not clear ->child_reaper or leave it alone.
184 pid_ns->child_reaper = NULL; 184 * There may by stealth EXIT_DEAD tasks on ->children,
185 * forget_original_parent() must move them somewhere.
186 */
187 pid_ns->child_reaper = init_pid_ns.child_reaper;
185 acct_exit_ns(pid_ns); 188 acct_exit_ns(pid_ns);
186 return; 189 return;
187} 190}