|| ||Tejun Heo <email@example.com> |
|| ||firstname.lastname@example.org, email@example.com, firstname.lastname@example.org,
email@example.com, firstname.lastname@example.org |
|| ||[PATCHSET] ptrace,signal: sane interaction between ptrace and job control signals, take#2 |
|| ||Mon, 6 Dec 2010 17:56:48 +0100|
|| ||Article, Thread
This is the second attempt at cleaning up ptrace and signal behaviors,
especially the interaction between ptrace and group stop. There are
quite some number of problems in the area and the current behavior is
often racy, indeterministic and sometimes outright buggy. This
patchset aims to clean up the muddy stuff, and define and implement a
clear interaction between ptrace and job control.
Most changes from the last take[L] are to address the problems pointed
out by Oleg. Let's hope things are less swiss-cheesy this time. I
considered adding a separate task state tracking which encompasses
ptrace related transitions but it quickly became too redundant and
uglier than the current approach of augmenting the default state
machine with flags for special cases. So, at least for now, I think
it's better to continue with the current approach.
* Group stop helpers restructured: task_clear_group_stop[_trapping]()
added and consume_group_stop() replaced with
* 0002-freezer-fix-a-race-during-freezing-of-TASK_STOPPED-t.patch from
the last posting was taken by Rafael and dropped from this series.
* 0002-signal-fix-CLD_CONTINUED-notification-target.patch added.
replaced with 0004-ptrace-kill-tracehook_notify_jctl.patch to
streamline the conversion. Whether something similar can or should
be factored out after conversion is to be determined but I'm quite
* 0005-ptrace-add-why-to-ptrace_stop.patch repositioned from 0007 to
Fixed the problems pointed out by Oleg.
This is to ensure that GROUP_STOP_PENDING consumption and transition
into TASK_TRACED is atomic so that a task doesn't trap for group
stop with GROUP_STOP_PENDING set.
Fixed group stop bookkeeping bug on retry. TASK_STOPPED ->
TASK_TRACED transition is now hidden from userland with the help of
* Notification reliability patches restructured so that the
determination logics now reside in do_notify_parent_cldstop() and
are executed while holding both tasklist_lock and siglock.
* New patches 0011 and 0015 added.
This patchset contains the following sixteen patches.
0001-0002 are fixes. 0003-0005 are preparation patches.
0006 prevents a ptraced task from being stopped multiple times for the
same group stop instance.
0007-0010 update the code such that a ptracee always enters and leaves
TASK_TRACED on its own. ptracer no longer changes tracee's state
underneath it; instead, it tells the tracee to enter the target state.
A TASK_TRACED task is guaranteed to be stopped inside ptrace_stop()
after executing the arch hooks while TASK_STOPPED task is guaranteed
to be stopped in do_signal_stop().
0011-0015 make CLD_STOPPED/CONTINUED notification reliable with
intervening ptrace. Whether a ptracee owes an notification to its
parent is tracked and the real parent is notified accordingly on
0016 kills the unnecessary wake_up_process() which is wrong in so many
ways including the possibility of abruptly waking up a task in an
uninterruptible sleep. Now that ptrace / job control interaction is
cleaned up, this really should go.
After the patchset, the interaction between ptrace and job control is
* Regardless of ptrace, job control signals control the process-wide
stopped state. A ptracee receives and handles job control signals
the same as before but no matter what ptrace does the global state
* On ptrace detach, the task is put into the state which matches the
process-wide stopped state. If necessary, notification to the real
parent is reinstated.
Due to the implicit sending of SIGSTOP on PTRACE_ATTACH, ptrace
attach/detach are still not transparent w.r.t. job control but these
changes lay the base for (almost) transparent ptracing.
The branch is on top of 2.6.37-rc4 and available in the following git
and contains the following changes.
fs/exec.c | 1
include/linux/sched.h | 14 +
include/linux/tracehook.h | 27 ---
kernel/ptrace.c | 139 ++++++++++++++----
kernel/signal.c | 345 +++++++++++++++++++++++++++++++++++-----------
5 files changed, 391 insertions(+), 135 deletions(-)