Re: hit a KASan bug related to Perf during stress test

From: Peter Zijlstra
Date: Wed Oct 26 2016 - 05:03:44 EST


On Tue, Oct 25, 2016 at 04:41:26PM +0200, Oleg Nesterov wrote:
> >
> > So what serialization would close that race? __task_pid_nr_ns() only
> > seems to use RCU nothing more.
>
> I do not see how can we close this race, we obviously do not want to use
> any locking.
>
> That is why I tried to suggest
>
> nr = __task_pid_nr_ns(p, type, event->ns);
> if (!nr && !is_idle_task(p))
> nr = -1;
> return nr;
>
> but this will report -1 if p runs in another namespace, so perhaps we
> can do
>
> nr = __task_pid_nr_ns(p, type, event->ns);
> if (!nr && p->exit_state)
> // it has already called exit_notify
> nr = -1;
> return nr;

I think I'm asking how __task_pid_nr_ns() isn't susceptible to this race
;-)