android_kernel_motorola_sm6225/arch/sparc/kernel
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
..
apc.c [PATCH] mark struct file_operations const 2 2007-02-12 09:48:44 -08:00
asm-offsets.c sparc: use kbuild.h instead of defining macros in asm-offsets.c 2008-04-29 08:06:29 -07:00
auxio.c [SPARC]: Spelling fixes. 2007-05-11 21:39:20 -07:00
cpu.c [SPARC]: Mark linux_sparc_{fpu,chips} static. 2008-02-28 21:46:59 -08:00
devices.c [SPARC]: Add missing of_node_put 2007-12-05 05:38:00 -08:00
ebus.c sparc: replace remaining __FUNCTION__ occurances 2008-03-03 11:41:51 -08:00
entry.S sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
etrap.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
head.S sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
idprom.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
init_task.c Remove fs.h from mm.h 2007-07-29 17:09:29 -07:00
ioport.c Spelling fixes: lenght->length 2008-02-03 15:42:53 +02:00
irq.c [SPARC]: Remove duplicate includes. 2007-11-06 21:23:11 -08:00
irq.h [SPARC32]: Take enable_irq/disable_irq out of line. 2007-07-21 19:19:38 -07:00
kgdb.c sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
led.c [SPARC]: Fix build in arch/sparc/kernel/led.c 2008-02-24 18:45:09 -08:00
Makefile sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
module.c [SPARC]: Handle UNWIND_INFO properly. 2006-05-12 12:45:50 -07:00
muldiv.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
of_device.c [SPARC]: Remove of_platform_device_create 2008-02-09 03:49:58 -08:00
pcic.c xtime_lock vs update_process_times 2008-02-13 13:29:25 -08:00
pmc.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
process.c sparc32: Don't twiddle PT_DTRACE in exec. 2008-05-10 00:31:28 -07:00
prom.c [SPARC]: Centralize find_in_proplist() instead of duplicating N times. 2007-08-07 18:46:36 -07:00
ptrace.c sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
rtrap.S sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
setup.c sparc32: More memory probing consolidation. 2008-05-02 05:22:53 -07:00
signal.c sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
smp.c [SPARC32]: clean include/asm-sparc/irq.h 2007-07-21 19:18:57 -07:00
sparc_ksyms.c sparc: Export symbols for ZERO_PAGE usage in modules. 2008-04-29 08:11:12 -04:00
sun4c_irq.c [SPARC32]: clean include/asm-sparc/irq.h 2007-07-21 19:18:57 -07:00
sun4d_irq.c [SPARC32]: Take enable_irq/disable_irq out of line. 2007-07-21 19:19:38 -07:00
sun4d_smp.c sparc32: Kill smp_message_pass() and related code. 2008-04-29 01:14:10 -07:00
sun4m_irq.c [SPARC32]: clean include/asm-sparc/irq.h 2007-07-21 19:18:57 -07:00
sun4m_smp.c sparc32: Kill smp_message_pass() and related code. 2008-04-29 01:14:10 -07:00
sun4setup.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sys_sparc.c sparc: Fix mmap VA span checking. 2008-05-07 02:24:28 -07:00
systbls.S [SPARC]: Remove SunOS and Solaris binary support. 2008-04-21 15:10:15 -07:00
tadpole.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
tick14.c [SPARC32]: Take enable_irq/disable_irq out of line. 2007-07-21 19:19:38 -07:00
time.c [SPARC] minor irq handler cleanups 2008-04-20 18:43:05 -04:00
trampoline.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
traps.c Use helpers to obtain task pid in printks (arch code) 2007-10-19 11:53:43 -07:00
una_asm.S [SPARC]: Fix link errors with gcc-4.3 2008-03-03 15:01:05 -08:00
unaligned.c [SPARC]: Fix link errors with gcc-4.3 2008-03-03 15:01:05 -08:00
vmlinux.lds.S [SPARC]: Merge asm-sparc{,64}/cache.h 2008-02-09 04:17:37 -08:00
windows.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
wof.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
wuf.S Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00