2001-02-21 22:02:46

by Christian Ehrhardt

[permalink] [raw]
Subject: Long standing bug in alternate stack handling


Hi,

I just found this out the hard way:

If a signal handler is registered with the SA_ONSTACK flag the
kernel will try to execute the signal handler on the alternate
stack even if no such stack is registered.
This is an explicit violation of Unix98 and probably Posix.

Architectures affected include at least i386 (don't know about others).


regards Christian

--
THAT'S ALL FOLKS!


2001-04-25 22:14:12

by Christian Ehrhardt

[permalink] [raw]
Subject: Re: Long standing bug in alternate stack handling

On Wed, Feb 21, 2001 at 11:02:17PM +0100, Christian Ehrhardt wrote:

Hi,

[ Sorry for the follow up on my own post ]

> If a signal handler is registered with the SA_ONSTACK flag the
> kernel will try to execute the signal handler on the alternate
> stack even if no such stack is registered.

Here's a simple patch for i386. Please consider it for inclusion.
Posix explicitly requires the behaviour implemented by this patch.


--- arch/i386/kernel/signal.c.old Mon Sep 25 22:10:28 2000
+++ arch/i386/kernel/signal.c Sun Apr 22 16:04:47 2001
@@ -371,7 +371,7 @@

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

NOTE: As far as I can tell all archs are affected by this bug.

best regards Christian Ehrhardt

--
THAT'S ALL FOLKS!