kernel-ark/arch
David S. Miller 28e6103665 sparc: Fix debugger syscall restart interactions.
So, forever, we've had this ptrace_signal_deliver implementation
which tries to handle all of the nasties that can occur when the
debugger looks at a process about to take a signal.  It's meant
to address all of these issues inside of the kernel so that the
debugger need not be mindful of such things.

Problem is, this doesn't work.

The idea was that we should do the syscall restart business first, so
that the debugger captures that state.  Otherwise, if the debugger for
example saves the child's state, makes the child execute something
else, then restores the saved state, we won't handle the syscall
restart properly because we lose the "we're in a syscall" state.

The code here worked for most cases, but if the debugger actually
passes the signal through to the child unaltered, it's possible that
we would do a syscall restart when we shouldn't have.

In particular this breaks the case of debugging a process under a gdb
which is being debugged by yet another gdb.  gdb uses sigsuspend
to wait for SIGCHLD of the inferior, but if gdb itself is being
debugged by a top-level gdb we get a ptrace_stop().  The top-level gdb
does a PTRACE_CONT with SIGCHLD to let the inferior gdb see the
signal.  But ptrace_signal_deliver() assumed the debugger would cancel
out the signal and therefore did a syscall restart, because the return
error was ERESTARTNOHAND.

Fix this by simply making ptrace_signal_deliver() a nop, and providing
a way for the debugger to control system call restarting properly:

1) Report a "in syscall" software bit in regs->{tstate,psr}.
   It is set early on in trap entry to a system call and is fully
   visible to the debugger via ptrace() and regsets.

2) Test this bit right before doing a syscall restart.  We have
   to do a final recheck right after get_signal_to_deliver() in
   case the debugger cleared the bit during ptrace_stop().

3) Clear the bit in trap return so we don't accidently try to set
   that bit in the real register.

As a result we also get a ptrace_{is,clear}_syscall() for sparc32 just
like sparc64 has.

M68K has this same exact bug, and is now the only other user of the
ptrace_signal_deliver hook.  It needs to be fixed in the same exact
way as sparc.

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-11 02:07:19 -07:00
..
alpha [PATCH] make osf_select() use core_sys_select() 2008-05-01 13:07:28 -04:00
arm unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
avr32 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
blackfin unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
cris cris: use non-racy method for /proc/system_profile creation 2008-04-29 08:06:21 -07:00
frv unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
h8300 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
ia64 Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6 2008-05-02 08:17:58 -07:00
m32r m32r: cleanup: drop .data.idt section in vmlinux.lds script 2008-04-29 14:46:00 +09:00
m68k unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
m68knommu unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
mips Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6 2008-05-02 11:23:14 -07:00
mn10300 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
parisc unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
powerpc unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
ppc Basic braille screen reader support 2008-04-30 08:29:52 -07:00
s390 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
sh unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
sparc sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
sparc64 sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
um unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
v850 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
x86 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
xtensa xtensa: use kbuild.h macros instead of defining them in asm-offsets.c 2008-04-29 08:06:29 -07:00
.gitignore
Kconfig dma: add dma_*map*_attrs() interfaces 2008-04-29 08:06:11 -07:00