[lkml]   [2011]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[PATCHSET ptrace] ptrace: implement PTRACE_SEIZE/INTERRUPT and group stop notification

This patchset implements new ptrace requests SEIZE and INTERRUPT and
also add group stop notification mechanism for ptracer. Combined,
this implements "P4. PTRACE_SEIZE" and "P5. ^Z and fg for tracees" of
the ptrace job control improvements proposal[1].

Please note that there are some deviations from the proposal.

* As suggested by Oleg, PTRACE_SEIZE only serves as ATTACH without
signal/job control side-effects. After attached, PTRACE_INTERRUPT
should be used to trap tracee without side effect.

* Group stop notification is implemented as sticky INTERRUPT trap
which gets cleared on PTRACE_GETSIGINFO and notifies both start and
end of group stops.

All the arch changse are for adding siginfo.si_pt_flags. It's tedious
and likely to take some time to be available to userland but I think
it's better this way than adding some hacky flag to si_code or other
already used fields.

PTRACE_SEIZE/INTERRUPT and group stop notification all use INTERRUPT
trap. The trap doesn't affect signal or job control states and is the
job control mechanism for ptracer in the sense that all it does is
just controlling the execution of tracee.

SEIZE/INTERRUPT behaviors are fairly straight-forward. For
notification, making group stop state visible to userland via
PTRACE_GETSIGINFO was easy; however, notifying ptracer of the event
was somewhat more involved. I ended up choosing the followings.

* The trap condition is sticky until GETSIGINFO. This is necessary
because generation of the event may race with CONT and ptracer may
miss the trap.

* If tracee is running, simple trapping is enough. If tracee is
already group stop or INTERRUPT trapped, tracee is re-trapped to
INTERRUPT thus notifying ptracer. If tracee is in other traps,
notification won't happen until the trap is finished. This
simplifies both implementation and usage of the interface and
doesn't lose any capability as tracer can always put tracee into
INTERRUPT trap if it's already in a trap without allowing it to
return to userland.

* If group stop is pending, it has higher priority than INTERRUPT.
This doesn't really affect correctness but avoids an extra
notification trap if tracee is already going for group stop.

Each patch implementing new feature includes test program showing its
functionality. Notification would probably need a bit more polishing
but all the needed functionalities are there.

This patchset contains the following 11 patches.


and on top of

Oleg's signals-review b013c39924 (signal: cleanup sys_sigprocmask())
+ [2] ptrace: fix signal->wait_chldexit usage in task_clear_group_stop_trapping()
+ [3] ptrace: use GROUP_STOP_TRAPPING for PTRACE_DETACH too

The combined patchset is available in the following git branch.

git:// review-ptrace-seize

HEAD should be 74b094e53f38691c98ab73499e59eb7d5771dd4c. If not,
git.korg is tasking some time to sync so please wait a while and try
again, or you can pull from master directly.

ssh:// review-ptrace-seize

diffstat follows.

arch/ia64/include/asm/siginfo.h | 7 +
arch/ia64/kernel/signal.c | 5
arch/mips/include/asm/compat-signal.h | 7 +
arch/mips/include/asm/siginfo.h | 7 +
arch/mips/kernel/signal32.c | 5
arch/parisc/kernel/signal32.c | 5
arch/parisc/kernel/signal32.h | 7 +
arch/powerpc/kernel/ppc32.h | 7 +
arch/powerpc/kernel/signal_32.c | 5
arch/s390/kernel/compat_linux.h | 7 +
arch/s390/kernel/compat_signal.c | 5
arch/sparc/kernel/signal32.c | 12 +
arch/tile/kernel/compat_signal.c | 11 +
arch/x86/ia32/ia32_signal.c | 4
arch/x86/include/asm/ia32.h | 7 +
fs/exec.c | 2
include/asm-generic/siginfo.h | 10 +
include/linux/ptrace.h | 14 ++
include/linux/sched.h | 26 ++--
kernel/exit.c | 49 ++++++-
kernel/ptrace.c | 193 ++++++++++++++++++++++++++----
kernel/signal.c | 213 +++++++++++++++++++++++++---------
22 files changed, 506 insertions(+), 102 deletions(-)

Thank you.



 \ /
  Last update: 2011-05-08 17:51    [W:0.472 / U:13.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site