diff options
author | David S. Miller <davem@davemloft.net> | 2008-05-11 05:07:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-05-11 05:07:19 -0400 |
commit | 28e6103665301ce60634e8a77f0b657c6cc099de (patch) | |
tree | 1ba78c7db8d139529b8f0db5f0de60a6fbf701cb /include/asm-sparc64/signal.h | |
parent | 986bef854fab44012df678a5b51817d5274d3ca1 (diff) |
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>
Diffstat (limited to 'include/asm-sparc64/signal.h')
-rw-r--r-- | include/asm-sparc64/signal.h | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h index fa6f467389db..c49f32d38707 100644 --- a/include/asm-sparc64/signal.h +++ b/include/asm-sparc64/signal.h | |||
@@ -186,13 +186,7 @@ struct k_sigaction { | |||
186 | void __user *ka_restorer; | 186 | void __user *ka_restorer; |
187 | }; | 187 | }; |
188 | 188 | ||
189 | struct signal_deliver_cookie { | 189 | #define ptrace_signal_deliver(regs, cookie) do { } while (0) |
190 | int restart_syscall; | ||
191 | unsigned long orig_i0; | ||
192 | }; | ||
193 | |||
194 | struct pt_regs; | ||
195 | extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie); | ||
196 | 190 | ||
197 | #endif /* !(__KERNEL__) */ | 191 | #endif /* !(__KERNEL__) */ |
198 | 192 | ||