ptrace: ensure JOBCTL_STOP_SIGMASK is not zero after detach
commit2c60e18b07e8e08c7e3b6cc8288b0e04e18844f7
authorOleg Nesterov <oleg@redhat.com>
Wed, 4 Jan 2012 16:29:20 +0000 (4 17:29 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 6 Jan 2012 22:17:34 +0000 (6 14:17 -0800)
treedf8b16065898d83dde5dc78149990bbf90486c0c
parent9e83ca1fcff0eee2ea7ef2508de95691a0cdeb0c
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>
kernel/ptrace.c
kernel/signal.c