linux-hardened/include
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
..
acpi ACPICA: update Intel copyright 2008-04-23 23:00:13 -04:00
asm-alpha alpha: types: use <asm-generic/int-*.h> for the alpha architecture 2008-05-02 16:18:20 -07:00
asm-arm arm: types: use <asm-generic/int-*.h> for the arm architecture 2008-05-02 16:18:20 -07:00
asm-avr32 avr32: types: use <asm-generic/int-*.h> for the avr32 architecture 2008-05-02 16:18:20 -07:00
asm-blackfin blackfin: types: use <asm-generic/int-*.h> for the blackfin architecture 2008-05-02 16:18:20 -07:00
asm-cris cris: types: use <asm-generic/int-*.h> for the cris architecture 2008-05-02 16:18:20 -07:00
asm-frv frv: types: use <asm-generic/int-*.h> for the frv architecture 2008-05-02 16:18:20 -07:00
asm-generic types: add C99-style constructors to <asm-generic/int-*.h> 2008-05-02 16:18:42 -07:00
asm-h8300 h8300: types: use <asm-generic/int-*.h> for the h8300 architecture 2008-05-02 16:18:21 -07:00
asm-ia64 ia64: types: use <asm-generic/int-*.h> for the ia64 architecture 2008-05-02 16:18:21 -07:00
asm-m32r m32r: types: use <asm-generic/int-*.h> for the m32r architecture 2008-05-02 16:18:21 -07:00
asm-m68k m68k: types: use <asm-generic/int-*.h> for the m68k architecture 2008-05-02 16:18:28 -07:00
asm-m68knommu m68knommu: rework definition of HZ 2008-05-01 08:08:36 -07:00
asm-mips mips: types: use <asm-generic/int-*.h> for the mips architecture 2008-05-02 16:18:29 -07:00
asm-mn10300 mn10300: types: use <asm-generic/int-*.h> for the mn10300 architecture 2008-05-02 16:18:31 -07:00
asm-parisc parisc: types: use <asm-generic/int-*.h> for the parisc architecture 2008-05-02 16:18:32 -07:00
asm-powerpc unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
asm-ppc [RAPIDIO] Move include/asm-ppc/rio.h to asm-powerpc 2008-04-29 19:40:27 +10:00
asm-s390 s390: types: use <asm-generic/int-*.h> for the s390 architecture 2008-05-02 16:18:40 -07:00
asm-sh sh: types: use <asm-generic/int-*.h> for the sh architecture 2008-05-02 16:18:40 -07:00
asm-sparc sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
asm-sparc64 sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
asm-um rename div64_64 to div64_u64 2008-05-01 08:03:58 -07:00
asm-v850 v850: types: use <asm-generic/int-*.h> for the v850 architecture 2008-05-02 16:18:41 -07:00
asm-x86 x86: types: use <asm-generic/int-*.h> for the x86 architecture 2008-05-02 16:18:42 -07:00
asm-xtensa xtensa: types: use <asm-generic/int-*.h> for the xtensa architecture 2008-05-02 16:18:42 -07:00
crypto [CRYPTO] api: Fix scatterwalk_sg_chain 2008-05-01 18:22:28 +08:00
keys KEYS: Fix the comment to match the file name in rxrpc-type.h. 2008-04-21 22:43:55 +00:00
linux Merge git://git.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt 2008-05-03 13:51:10 -07:00
math-emu
media Merge git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/v4l-dvb 2008-04-29 14:53:40 -07:00
mtd
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6 2008-04-30 08:45:48 -07:00
pcmcia
rdma IB: expand ib_umem_get() prototype 2008-04-29 08:06:12 -07:00
rxrpc
scsi Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2008-05-02 13:52:35 -07:00
sound [ALSA] Add MPU401_INFO_NO_ACK bitflag 2008-04-29 19:01:56 +02:00
video fbdev: platforming hecubafb and n411 2008-04-28 08:58:41 -07:00
xen xen: add balloon driver 2008-04-24 23:57:33 +02:00
Kbuild