Skip to content

Commit

Permalink
[PATCH] fix incorrect SA_ONSTACK behaviour for 64-bit processes
Browse files Browse the repository at this point in the history
- When setting a sighandler using sigaction() call, if the flag
  SA_ONSTACK is set and no alternate stack is provided via sigaltstack(),
  the kernel still try to install the alternate stack.  This behavior is
  the opposite of the one which is documented in Single Unix Specifications
  V3.

- Also when setting an alternate stack using sigaltstack() with the flag
  SS_DISABLE, the kernel try to install the alternate stack on signal
  delivery.

These two use cases makes the process crash at signal delivery.

Signed-off-by: Laurent Meyer <meyerlau@fr.ibm.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: David Howells <dhowells@redhat.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Laurent MEYER authored and Linus Torvalds committed Jun 23, 2006
1 parent 785d557 commit d09042d
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion arch/alpha/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame, struct pt_regs *regs,
static inline void __user *
get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
{
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
sp = current->sas_ss_sp + current->sas_ss_size;

return (void __user *)((sp - frame_size) & -32ul);
Expand Down
2 changes: 1 addition & 1 deletion arch/frv/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,

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

Expand Down
2 changes: 1 addition & 1 deletion arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)

/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa.sa_flags & SA_ONSTACK) {
if (!on_sig_stack(usp))
if (!sas_ss_flags(usp))
usp = current->sas_ss_sp + current->sas_ss_size;
}
return (void *)((usp - frame_size) & -8UL);
Expand Down
2 changes: 1 addition & 1 deletion arch/m68k/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)

/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa.sa_flags & SA_ONSTACK) {
if (!on_sig_stack(usp))
if (!sas_ss_flags(usp))
usp = current->sas_ss_sp + current->sas_ss_size;
}
return (void __user *)((usp - frame_size) & -8UL);
Expand Down
2 changes: 1 addition & 1 deletion arch/m68knommu/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)

/* This is the X/Open sanctioned signal stack switching. */
if (ka->sa.sa_flags & SA_ONSTACK) {
if (!on_sig_stack(usp))
if (!sas_ss_flags(usp))
usp = current->sas_ss_sp + current->sas_ss_size;
}
return (void *)((usp - frame_size) & -8UL);
Expand Down
2 changes: 1 addition & 1 deletion arch/parisc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
DBG(1,"get_sigframe: ka = %#lx, sp = %#lx, frame_size = %#lx\n",
(unsigned long)ka, sp, frame_size);

if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
sp = current->sas_ss_sp; /* Stacks grow up! */

DBG(1,"get_sigframe: Returning sp = %#lx\n", (unsigned long)sp);
Expand Down
2 changes: 1 addition & 1 deletion arch/sh64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
static inline void __user *
get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
{
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
sp = current->sas_ss_sp + current->sas_ss_size;

return (void __user *)((sp - frame_size) & -8ul);
Expand Down
2 changes: 1 addition & 1 deletion arch/v850/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, size_t frame_size)
/* Default to using normal stack */
unsigned long sp = regs->gpr[GPR_SP];

if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
sp = current->sas_ss_sp + current->sas_ss_size;

return (void *)((sp - frame_size) & -8UL);
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
static inline void *
get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
{
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! on_sig_stack(sp))
if ((ka->sa.sa_flags & SA_ONSTACK) != 0 && ! sas_ss_flags(sp))
sp = current->sas_ss_sp + current->sas_ss_size;

return (void *)((sp - frame_size) & -16ul);
Expand Down

0 comments on commit d09042d

Please sign in to comment.