All architectures in the kernel increment/decrement the stack pointerbefore storing values on the stack.

On architectures which have the stack grow down sas_ss_sp == sp is noton the alternate signal stack while sas_ss_sp + sas_ss_size == sp ison the alternate signal stack.

On architectures which have the stack grow up sas_ss_sp == sp is onthe alternate signal stack while sas_ss_sp + sas_ss_size == sp is noton the alternate signal stack.

The current implementation fails for architectures which have thestack grow down on the corner case where sas_ss_sp == sp.This wasreported as Debian bug #544905 on AMD64.Simplified test case: http://download.breakpoint.cc/tc-sig-stack.c

If the signal is sent the stack pointer is pointing to the baseaddress of the alt stack and the kernel erroneously decides that ithas already switched to the alternate stack because of the currentcheck for "sp - sas_ss_sp < sas_ss_size"

[ tglx: Modified for archs which have the stack grow up (parisc) which would fail with the correct implementation for stack grows down. Added a check for sp >= current->sas_ss_sp which is strictly not necessary but makes the code symetric for both variants ]