Re: [PATCH 2/2] exit: pidns: alloc_pid() leaks pid_namespace if child_reaper is exiting

From: Oleg Nesterov
Date: Tue Nov 25 2014 - 13:59:33 EST


On 11/25, Eric W. Biederman wrote:
>
> Oleg Nesterov <oleg@xxxxxxxxxx> writes:
>
> > On 11/25, Eric W. Biederman wrote:
> >>
> >> My concern is exposing a half initialized struct pid to the world via an
> >> rcu data structure. In particular could one of the rcu users get into
> >> trouble because we haven't called get_pid_ns yet? That is unclear to me.
> >
> > They can't. This pid was fully initialized, in particular
> > pid->numbers[pid->level].ns == ns has a reference.
> >
> > Just it is not ready for put_pid() which will be called by the "owner" of
> > this pid, the caller or the new child. So in this sense it doesn't matter
> > when we call get_pid_ns(), just we need to do this before return.
>
> Or by someone calling find_get_pid() ... put_pid().
>
> Now the reference count should not hit zero in that case

Yes. this get_pid_ns() connects to atomic_set(&pid->count, 1) set by us.

> but I hate to
> think of that case separately.

OK.

> At this point, and especially since we need to Cc stable and get this
> fix backported to who knows how many kernel releases having something
> that is trivial to validate is correct is important.

OK. I'll send V2 with -stable cc'ed.

Oleg.

--
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/