Re: [PATCH -mm 1/1] pidns: find_new_reaper() can no longer switch to init_pid_ns.child_reaper

From: Eric W. Biederman
Date: Fri May 25 2012 - 17:43:57 EST


Oleg Nesterov <oleg@xxxxxxxxxx> writes:

> find_new_reaper() changes pid_ns->child_reaper, see add0d4df
> "pid_ns: zap_pid_ns_processes: fix the ->child_reaper changing".
>
> The original reason has gone away after the previous patch,
> ->children list must be empty after zap_pid_ns_processes().
> However, "can't clear ->child_reaper or leave it alone" is
> still true, and now we can not use init_pid_ns.child_reaper.
>
> __unhash_process() relies on the "->child_reaper == parent"
> check, but this check does not work if the last exiting task
> is also the child reaper.
>
> Change find_new_reaper() to use pid_ns->parent->child_reaper.

Oleg this is a good catch for a real problem. However I disagree about
the fix.

We should make unhash_process say:
if ((task_active_pid_ns(parent)->child_reaper == parent) &&
list_empty(&parent->children) &&
(parent->flags & PF_EXITING))
wake_up_process(parent);

It is always the child_reaper of our parent's pid namespace that we are
reparented to if our parent exits. So we were looking at the wrong
processes pid_namespace. Just using parent removes any need for magic
after zap_pid_ns_processes(), and the test always becomes valid.

And we should just set delete the code after zap_pid_ns_processes that
changes the child_reaper since nothing we will use the child_reaper
after that. We could set pid_ns.child_reaper to NULL after that
but why bother.

Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/