Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
  sparc: Fix SA_ONSTACK signal handling.
  • Loading branch information
Linus Torvalds committed May 9, 2008
2 parents 8d53910 + dc5dc7e commit 89f92d6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
20 changes: 17 additions & 3 deletions arch/sparc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,29 @@ static inline int invalid_frame_pointer(void __user *fp, int fplen)

static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
{
unsigned long sp;
unsigned long sp = regs->u_regs[UREG_FP];

sp = regs->u_regs[UREG_FP];
/*
* If we are on the alternate signal stack and would overflow it, don't.
* Return an always-bogus address instead so we will die with SIGSEGV.
*/
if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
return (void __user *) -1L;

/* This is the X/Open sanctioned signal stack switching. */
if (sa->sa_flags & SA_ONSTACK) {
if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7))
if (sas_ss_flags(sp) == 0)
sp = current->sas_ss_sp + current->sas_ss_size;
}

/* Always align the stack frame. This handles two cases. First,
* sigaltstack need not be mindful of platform specific stack
* alignment. Second, if we took this signal because the stack
* is not aligned properly, we'd like to take the signal cleanly
* and report that.
*/
sp &= ~7UL;

return (void __user *)(sp - framesize);
}

Expand Down
21 changes: 17 additions & 4 deletions arch/sparc64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,16 +376,29 @@ save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)

static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize)
{
unsigned long sp;
unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;

sp = regs->u_regs[UREG_FP] + STACK_BIAS;
/*
* If we are on the alternate signal stack and would overflow it, don't.
* Return an always-bogus address instead so we will die with SIGSEGV.
*/
if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
return (void __user *) -1L;

/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa.sa_flags & SA_ONSTACK) {
if (!on_sig_stack(sp) &&
!((current->sas_ss_sp + current->sas_ss_size) & 7))
if (sas_ss_flags(sp) == 0)
sp = current->sas_ss_sp + current->sas_ss_size;
}

/* Always align the stack frame. This handles two cases. First,
* sigaltstack need not be mindful of platform specific stack
* alignment. Second, if we took this signal because the stack
* is not aligned properly, we'd like to take the signal cleanly
* and report that.
*/
sp &= ~7UL;

return (void __user *)(sp - framesize);
}

Expand Down
18 changes: 17 additions & 1 deletion arch/sparc64/kernel/signal32.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,27 @@ static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, uns
regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
sp = regs->u_regs[UREG_FP];

/*
* If we are on the alternate signal stack and would overflow it, don't.
* Return an always-bogus address instead so we will die with SIGSEGV.
*/
if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
return (void __user *) -1L;

/* This is the X/Open sanctioned signal stack switching. */
if (sa->sa_flags & SA_ONSTACK) {
if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7))
if (sas_ss_flags(sp) == 0)
sp = current->sas_ss_sp + current->sas_ss_size;
}

/* Always align the stack frame. This handles two cases. First,
* sigaltstack need not be mindful of platform specific stack
* alignment. Second, if we took this signal because the stack
* is not aligned properly, we'd like to take the signal cleanly
* and report that.
*/
sp &= ~7UL;

return (void __user *)(sp - framesize);
}

Expand Down

0 comments on commit 89f92d6

Please sign in to comment.