Skip to content

Commit

Permalink
m68k: Don't lose state if sigframe setup fails
Browse files Browse the repository at this point in the history
If we'd failed in setup_frame(), we've no place to store
the original sigmask.  It's not an unrecoverable situation -
we raise SIGSEGV, but that SIGSEGV might be successfully
handled (e.g. on altstack).  In that case we really don't
want sa_mask of original signal permanently slapped on
the set of blocked signals.

Standard solution: have setup_frame()/setup_rt_frame()
report failure and don't mess with the signal-related
state if that has happened...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
  • Loading branch information
Al Viro authored and Geert Uytterhoeven committed Jan 7, 2011
1 parent 9e4930d commit f85741e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions arch/m68k/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
return (void __user *)((usp - frame_size) & -8UL);
}

static void setup_frame (int sig, struct k_sigaction *ka,
static int setup_frame (int sig, struct k_sigaction *ka,
sigset_t *set, struct pt_regs *regs)
{
struct sigframe __user *frame;
Expand Down Expand Up @@ -813,14 +813,14 @@ static void setup_frame (int sig, struct k_sigaction *ka,
tregs->pc = regs->pc;
tregs->sr = regs->sr;
}
return;
return err;

give_sigsegv:
force_sigsegv(sig, current);
goto adjust_stack;
}

static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
static int setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *set, struct pt_regs *regs)
{
struct rt_sigframe __user *frame;
Expand Down Expand Up @@ -901,7 +901,7 @@ static void setup_rt_frame (int sig, struct k_sigaction *ka, siginfo_t *info,
tregs->pc = regs->pc;
tregs->sr = regs->sr;
}
return;
return err;

give_sigsegv:
force_sigsegv(sig, current);
Expand Down Expand Up @@ -963,16 +963,20 @@ static void
handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *oldset, struct pt_regs *regs)
{
int err;
/* are we from a system call? */
if (regs->orig_d0 >= 0)
/* If so, check system call restarting.. */
handle_restart(regs, ka, 1);

/* set up the stack frame */
if (ka->sa.sa_flags & SA_SIGINFO)
setup_rt_frame(sig, ka, info, oldset, regs);
err = setup_rt_frame(sig, ka, info, oldset, regs);
else
setup_frame(sig, ka, oldset, regs);
err = setup_frame(sig, ka, oldset, regs);

if (err)
return;

sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
if (!(ka->sa.sa_flags & SA_NODEFER))
Expand All @@ -983,6 +987,8 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
regs->sr &= ~0x8000;
send_sig(SIGTRAP, current, 1);
}

clear_thread_flag(TIF_RESTORE_SIGMASK);
}

/*
Expand All @@ -1008,7 +1014,6 @@ asmlinkage void do_signal(struct pt_regs *regs)
if (signr > 0) {
/* Whee! Actually deliver the signal. */
handle_signal(signr, &ka, &info, oldset, regs);
clear_thread_flag(TIF_RESTORE_SIGMASK);
return;
}

Expand Down

0 comments on commit f85741e

Please sign in to comment.