Re: [PATCH 10/11] ptrace: move JOBCTL_TRAPPING wait to wait(2) andptrace_check_attach()
From: Oleg Nesterov
Date: Wed May 11 2011 - 13:02:41 EST
On 05/11, Oleg Nesterov wrote:
>
> You know, I'd wish I could find the serious bugs in this patch. The
> code becomes really hairy. -EAGAIN in do_wait() doesn't make it more
> simple ;)
Mwahaha! I seem to see the bug ;)
bool ptrace_wait_trapping(struct task_struct *child)
__releases(&child->sighand->siglock)
__releases(&tasklist_lock)
{
if (likely(!(child->jobctl & JOBCTL_TRAPPING)))
return false;
spin_unlock_irq(&child->sighand->siglock);
get_task_struct(child);
read_unlock(&tasklist_lock);
--> WINDOW
wait_event(current->signal->wait_chldexit,
!(child->jobctl & JOBCTL_TRAPPING));
put_task_struct(child);
return true;
}
When the caller is do_wait(), we can't assume we are the tracer when
we drop tasklist. Original tracer can detach, then another unrelated
process can attach again and provoke JOBCTL_TRAPPING. wait_event()
can hang forever.
Unfortunately, this is easy to fix :/
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/