Peter, Let me add another note. TASK_TRACED/TASK_STOPPED was always protected by ->siglock. In particular, ttwu(__TASK_TRACED) must be always called with ->siglock held. That is why ptrace_freeze_traced() assumes it can safely do s/TASK_TRACED/__TASK_TRACED/ under spin_lock(siglock).
Can this change race with if (signal_pending_state(prev->state, prev)) { prev->state = TASK_RUNNING; } in __schedule() ? Hopefully not, signal-state is protected by siglock too. So I think this logic was correct even if it doesn't look nice. But "doesn't look nice" is true for the whole ptrace code ;) On 07/20, Oleg Nesterov wrote: > > On 07/20, Jiri Slaby wrote: > > > > You tackled it, we cherry-picked dbfb089d360 to our kernels. Ccing more > > people. > > Thanks... so with this patch __schedule() does > > prev_state = prev->state; > > ... > > if (!preempt && prev_state && prev_state == prev->state) { > if (signal_pending_state(prev_state, prev)) { > prev->state = TASK_RUNNING; > } else { > > and ptrace_freeze_traced() can change ->state in between. This means > that this task can return from __schedule() with ->state != RUNNING, > this can explain BUG_ON(task_is_stopped_or_traced) in do_notify_parent() > you reported. > > Oleg.