summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2004-11-01 01:03:00 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-01 01:03:00 -0800
commit1b4ecbc76777dc7be4fcfafec3c2da3616333cee (patch)
tree54fe74ef9dcd156f9fbf192e10d7957b0a4580d3
parentf146e441c5ef0d0a2806c4ec9475030708adc475 (diff)
[PATCH] parisc: signal race fixes
Signal race fixes Committed-by: Carlos O'Donell <carlos@parisc-linux.org> Committed-by: James Bottomley <jejb@parisc-linux.org>
-rw-r--r--arch/parisc/kernel/signal.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
index b220bb22f79c..4a0a8adbc79d 100644
--- a/arch/parisc/kernel/signal.c
+++ b/arch/parisc/kernel/signal.c
@@ -494,11 +494,9 @@ give_sigsegv:
*/
static long
-handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
- struct pt_regs *regs, int in_syscall)
+handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
+ sigset_t *oldset, struct pt_regs *regs, int in_syscall)
{
- struct k_sigaction *ka = &current->sighand->action[sig-1];
-
DBG(1,"handle_signal: sig=%ld, ka=%p, info=%p, oldset=%p, regs=%p\n",
sig, ka, info, oldset, regs);
@@ -506,9 +504,6 @@ handle_signal(unsigned long sig, siginfo_t *info, sigset_t *oldset,
if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall))
return 0;
- if (ka->sa.sa_flags & SA_ONESHOT)
- ka->sa.sa_handler = SIG_DFL;
-
if (!(ka->sa.sa_flags & SA_NODEFER)) {
spin_lock_irq(&current->sighand->siglock);
sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
@@ -535,7 +530,7 @@ asmlinkage int
do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
{
siginfo_t info;
- struct k_sigaction *ka;
+ struct k_sigaction ka;
int signr;
DBG(1,"\ndo_signal: oldset=0x%p, regs=0x%p, sr7 %#lx, in_syscall=%d\n",
@@ -553,10 +548,15 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
oldset->sig[0], oldset->sig[1]);
- signr = get_signal_to_deliver(&info, regs, NULL);
- DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]);
+ /* May need to force signal if handle_signal failed to deliver */
+ while (1) {
+
+ signr = get_signal_to_deliver(&info, &ka, regs, NULL);
+ DBG(3,"do_signal: signr = %d, regs->gr[28] = %ld\n", signr, regs->gr[28]);
- if (signr > 0) {
+ if (signr <= 0)
+ break;
+
/* Restart a system call if necessary. */
if (in_syscall) {
/* Check the return code */
@@ -569,8 +569,7 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
break;
case -ERESTARTSYS:
- ka = &current->sighand->action[signr-1];
- if (!(ka->sa.sa_flags & SA_RESTART)) {
+ if (!(ka.sa.sa_flags & SA_RESTART)) {
DBG(1,"ERESTARTSYS: putting -EINTR\n");
regs->gr[28] = -EINTR;
break;
@@ -578,8 +577,7 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
/* fallthrough */
case -ERESTARTNOINTR:
/* A syscall is just a branch, so all
- we have to do is fiddle the return
- pointer. */
+ we have to do is fiddle the return pointer. */
regs->gr[31] -= 8; /* delayed branching */
/* Preserve original r28. */
regs->gr[28] = regs->orig_r28;
@@ -589,12 +587,13 @@ do_signal(sigset_t *oldset, struct pt_regs *regs, int in_syscall)
/* Whee! Actually deliver the signal. If the
delivery failed, we need to continue to iterate in
this loop so we can deliver the SIGSEGV... */
- if (handle_signal(signr, &info, oldset, regs, in_syscall)) {
+ if (handle_signal(signr, &info, &ka, oldset, regs, in_syscall)) {
DBG(1,KERN_DEBUG "do_signal: Exit (success), regs->gr[28] = %ld\n",
regs->gr[28]);
return 1;
}
}
+ /* end of while(1) looping forever if we can't force a signal */
/* Did we come from a system call? */
if (in_syscall) {