From: Rich Felker Date: Thu, 10 Mar 2011 15:17:29 +0000 (-0500) Subject: make sigaltstack work (missing macros in signal.h, error conditions) X-Git-Tag: v0.7.0~21 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6871fd773dcedbf056317d5d5e87b4859e97c4a4;p=oweals%2Fmusl.git make sigaltstack work (missing macros in signal.h, error conditions) --- diff --git a/arch/i386/bits/signal.h b/arch/i386/bits/signal.h index 4956a0d9..74d9d025 100644 --- a/arch/i386/bits/signal.h +++ b/arch/i386/bits/signal.h @@ -131,6 +131,8 @@ struct __siginfo #define POLL_HUP 6 #define SS_ONSTACK 1 #define SS_DISABLE 2 +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 #endif #define SA_NOCLDSTOP 1 diff --git a/arch/x86_64/bits/signal.h b/arch/x86_64/bits/signal.h index f2c92d09..ddebe90d 100644 --- a/arch/x86_64/bits/signal.h +++ b/arch/x86_64/bits/signal.h @@ -137,6 +137,8 @@ struct __siginfo #define POLL_HUP 6 #define SS_ONSTACK 1 #define SS_DISABLE 2 +#define MINSIGSTKSZ 2048 +#define SIGSTKSZ 8192 #endif #define SA_NOCLDSTOP 1 diff --git a/src/signal/sigaltstack.c b/src/signal/sigaltstack.c index 3cc2d456..6e46d098 100644 --- a/src/signal/sigaltstack.c +++ b/src/signal/sigaltstack.c @@ -1,8 +1,18 @@ #include +#include #include "syscall.h" int sigaltstack(const stack_t *ss, stack_t *old) { - /* depends on kernel struct matching */ + if (ss) { + if (ss->ss_size < MINSIGSTKSZ) { + errno = ENOMEM; + return -1; + } + if (ss->ss_flags & ~SS_DISABLE) { + errno = EINVAL; + return -1; + } + } return syscall2(__NR_sigaltstack, (long)ss, (long)old); }