aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-04-01 14:13:01 -0400
committerTejun Heo <tj@kernel.org>2011-04-03 20:11:05 -0400
commit321fb561971ba0f10ce18c0f8a4b9fbfc7cef4b9 (patch)
tree4123410887b549284ed32cf5e8fb799fd2540c14 /kernel
parentee77f075921730b2b465880f9fd4367003bdab39 (diff)
ptrace: ptrace_check_attach() should not do s/STOPPED/TRACED/
After "ptrace: Clean transitions between TASK_STOPPED and TRACED" d79fdd6d96f46fabb779d86332e3677c6f5c2a4f, 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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/ptrace.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 43485866749a..20d5efdeee02 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -112,16 +112,14 @@ int ptrace_check_attach(struct task_struct *child, int kill)
112 */ 112 */
113 read_lock(&tasklist_lock); 113 read_lock(&tasklist_lock);
114 if ((child->ptrace & PT_PTRACED) && child->parent == current) { 114 if ((child->ptrace & PT_PTRACED) && child->parent == current) {
115 ret = 0;
116 /* 115 /*
117 * child->sighand can't be NULL, release_task() 116 * child->sighand can't be NULL, release_task()
118 * does ptrace_unlink() before __exit_signal(). 117 * does ptrace_unlink() before __exit_signal().
119 */ 118 */
120 spin_lock_irq(&child->sighand->siglock); 119 spin_lock_irq(&child->sighand->siglock);
121 if (task_is_stopped(child)) 120 WARN_ON_ONCE(task_is_stopped(child));
122 child->state = TASK_TRACED; 121 if (task_is_traced(child) || kill)
123 else if (!task_is_traced(child) && !kill) 122 ret = 0;
124 ret = -ESRCH;
125 spin_unlock_irq(&child->sighand->siglock); 123 spin_unlock_irq(&child->sighand->siglock);
126 } 124 }
127 read_unlock(&tasklist_lock); 125 read_unlock(&tasklist_lock);