Skip to contentSkip to conversation

sigaltstack bad behavior on powerpc64

PATCH In review Laurent MEYER 3 participants 3 messages Mar 27, 2006 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sigaltstack bad behavior on powerpc64

Hello,

I may have found a bug in powerpc64 arch specific code.

*) 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.

I wrote a small patch to add a condition in get_sigframe().

Hope that is relevant and helpfull.

Regards,
Laurent MEYER.

arch/powerpc/kernel/signal_64.c +1 -1
Index: linux-2.6.16-mcr/arch/powerpc/kernel/signal_64.c
===================================================================
@@ -213,7 +213,7 @@
         /* Default to using normal stack */
         newsp = regs->gpr[1];
 
-	if (ka->sa.sa_flags & SA_ONSTACK) {
+	if ((ka->sa.sa_flags & SA_ONSTACK) && current->sas_ss_size) {
 		if (! on_sig_stack(regs->gpr[1]))
 			newsp = (current->sas_ss_sp + current->sas_ss_size);
 	}
#1 lore raw

arch/powerpc/kernel/signal_64.c line 217

Quoted 11 lines · Laurent MEYER

Index: linux-2.6.16-mcr/arch/powerpc/kernel/signal_64.c
===================================================================

arch/powerpc/kernel/signal_64.c +1 -1
@@ -213,7 +213,7 @@
         /* Default to using normal stack */
         newsp = regs->gpr[1];
 
-	if (ka->sa.sa_flags & SA_ONSTACK) {
+	if ((ka->sa.sa_flags & SA_ONSTACK) && current->sas_ss_size) {
 		if (! on_sig_stack(regs->gpr[1]))

This should use sas_ss_flags.

Andreas.

Signature · 4 lines
Andreas Schwab, SuSE Labs, [email protected]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#2 lore raw
In reply to Laurent MEYER
Quoted 1 line · Laurent MEYER

I may have found a bug in powerpc64 arch specific code.

Yes, you're right, it's a bug.

Quoted 1 line

I wrote a small patch to add a condition in get_sigframe().

Looks correct. Thanks. I'll put it in.

Paul.