summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2012-01-04 17:29:20 +0100
committerRohan Somvanshi <rsomvanshi@nvidia.com>2012-01-11 10:35:45 -0800
commitb04a20528569e49bd463a97d978fa50e796edcc8 (patch)
tree3867f4ae7e7f36dd0d1caab2f7155fc22ec9d18d /kernel
parentda156cf06a4d3260aa7cfbce976f68d1413c7dd8 (diff)
ptrace: ensure JOBCTL_STOP_SIGMASK is not zero after detach
commit 8a88951b5878dc475dcd841cefc767e36397d14e upstream. This is the temporary simple fix for 3.2, we need more changes in this area. 1. do_signal_stop() assumes that the running untraced thread in the stopped thread group is not possible. This was our goal but it is not yet achieved: a stopped-but-resumed tracee can clone the running thread which can initiate another group-stop. Remove WARN_ON_ONCE(!current->ptrace). 2. A new thread always starts with ->jobctl = 0. If it is auto-attached and this group is stopped, __ptrace_unlink() sets JOBCTL_STOP_PENDING but JOBCTL_STOP_SIGMASK part is zero, this triggers WANR_ON(!signr) in do_jobctl_trap() if another debugger attaches. Change __ptrace_unlink() to set the artificial SIGSTOP for report. Alternatively we could change ptrace_init_task() to copy signr from current, but this means we can copy it for no reason and hide the possible similar problems. Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Change-Id: I2c60e18b07e8e08c7e3b6cc8288b0e04e18844f7 Reviewed-on: http://git-master/r/74233 Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Tested-by: Varun Wadekar <vwadekar@nvidia.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/ptrace.c13
-rw-r--r--kernel/signal.c2
2 files changed, 12 insertions, 3 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index a70d2a5d8c7b..67d1fdd3c553 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -96,9 +96,20 @@ void __ptrace_unlink(struct task_struct *child)
*/
if (!(child->flags & PF_EXITING) &&
(child->signal->flags & SIGNAL_STOP_STOPPED ||
- child->signal->group_stop_count))
+ child->signal->group_stop_count)) {
child->jobctl |= JOBCTL_STOP_PENDING;
+ /*
+ * This is only possible if this thread was cloned by the
+ * traced task running in the stopped group, set the signal
+ * for the future reports.
+ * FIXME: we should change ptrace_init_task() to handle this
+ * case.
+ */
+ if (!(child->jobctl & JOBCTL_STOP_SIGMASK))
+ child->jobctl |= SIGSTOP;
+ }
+
/*
* If transition to TASK_STOPPED is pending or in TASK_TRACED, kick
* @child in the butt. Note that @resume should be used iff @child
diff --git a/kernel/signal.c b/kernel/signal.c
index 291c9700be75..195331c56ad3 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1986,8 +1986,6 @@ static bool do_signal_stop(int signr)
*/
if (!(sig->flags & SIGNAL_STOP_STOPPED))
sig->group_exit_code = signr;
- else
- WARN_ON_ONCE(!current->ptrace);
sig->group_stop_count = 0;