Skip to content

Commit 321fb56

Browse files
oleg-nesterovhtejun
authored andcommitted
ptrace: ptrace_check_attach() should not do s/STOPPED/TRACED/
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>
1 parent ee77f07 commit 321fb56

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

kernel/ptrace.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,14 @@ int ptrace_check_attach(struct task_struct *child, int kill)
112112
*/
113113
read_lock(&tasklist_lock);
114114
if ((child->ptrace & PT_PTRACED) && child->parent == current) {
115-
ret = 0;
116115
/*
117116
* child->sighand can't be NULL, release_task()
118117
* does ptrace_unlink() before __exit_signal().
119118
*/
120119
spin_lock_irq(&child->sighand->siglock);
121-
if (task_is_stopped(child))
122-
child->state = TASK_TRACED;
123-
else if (!task_is_traced(child) && !kill)
124-
ret = -ESRCH;
120+
WARN_ON_ONCE(task_is_stopped(child));
121+
if (task_is_traced(child) || kill)
122+
ret = 0;
125123
spin_unlock_irq(&child->sighand->siglock);
126124
}
127125
read_unlock(&tasklist_lock);

0 commit comments

Comments
 (0)