summaryrefslogtreecommitdiffstats
path: root/include/linux/ptrace.h
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2011-07-08 19:13:54 +0200
committerOleg Nesterov <oleg@redhat.com>2011-07-17 20:23:51 +0200
commitdcace06cc29df927a74a6bc0e57b9bef87704377 (patch)
tree9a04518032869b1ed79933026379ea0d7081e43a /include/linux/ptrace.h
parent6634ae1033ceaeca5877dd75723210f8c2648c17 (diff)
downloadlinux-dcace06cc29df927a74a6bc0e57b9bef87704377.tar.gz
linux-dcace06cc29df927a74a6bc0e57b9bef87704377.tar.bz2
linux-dcace06cc29df927a74a6bc0e57b9bef87704377.zip
ptrace: mv send-SIGSTOP from do_fork() to ptrace_init_task()
If the new child is traced, do_fork() adds the pending SIGSTOP. It assumes that either it is traced because of auto-attach or the tracer attached later, in both cases sigaddset/set_thread_flag is correct even if SIGSTOP is already pending. Now that we have PTRACE_SEIZE this is no longer right in the latter case. If the tracer does PTRACE_SEIZE after copy_process() makes the child visible the queued SIGSTOP is wrong. We could check PT_SEIZED bit and change ptrace_attach() to set both PT_PTRACED and PT_SEIZED bits simultaneously but see the next patch, we need to know whether this child was auto-attached or not anyway. So this patch simply moves this code to ptrace_init_task(), this way we can never race with ptrace_attach(). Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/ptrace.h')
-rw-r--r--include/linux/ptrace.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index fd8669fc339f..9b5d2c901d06 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -227,6 +227,9 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
if (unlikely(ptrace) && current->ptrace) {
child->ptrace = current->ptrace;
__ptrace_link(child, current->parent);
+
+ sigaddset(&child->pending.signal, SIGSTOP);
+ set_tsk_thread_flag(child, TIF_SIGPENDING);
}
}