Skip to content

Commit

Permalink
ptrace: ptrace_check_attach() should not do s/STOPPED/TRACED/
Browse files Browse the repository at this point in the history
After "ptrace: Clean transitions between TASK_STOPPED and TRACED"
d79fdd6, ptrace_check_attach()
should never see a TASK_STOPPED tracee and s/STOPPED/TRACED/ is
no longer legal. Add the warning.

Note: ptrace_check_attach() can be greatly simplified, in particular
it doesn't need tasklist. But I'd prefer another patch for that.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
  • Loading branch information
Oleg Nesterov authored and Tejun Heo committed Apr 4, 2011
1 parent ee77f07 commit 321fb56
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,14 @@ int ptrace_check_attach(struct task_struct *child, int kill)
*/
read_lock(&tasklist_lock);
if ((child->ptrace & PT_PTRACED) && child->parent == current) {
ret = 0;
/*
* child->sighand can't be NULL, release_task()
* does ptrace_unlink() before __exit_signal().
*/
spin_lock_irq(&child->sighand->siglock);
if (task_is_stopped(child))
child->state = TASK_TRACED;
else if (!task_is_traced(child) && !kill)
ret = -ESRCH;
WARN_ON_ONCE(task_is_stopped(child));
if (task_is_traced(child) || kill)
ret = 0;
spin_unlock_irq(&child->sighand->siglock);
}
read_unlock(&tasklist_lock);
Expand Down

0 comments on commit 321fb56

Please sign in to comment.