1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| | #include <signal.h>
#include <errno.h>
#include "syscall.h"
int sigaltstack(const stack_t *restrict ss, stack_t *restrict old)
{
// We must check requirements which Linux fails to verify in the syscall
// itself.
if (ss) {
// The syscall does already check against MINSIGSTKSZ, however,
// the kernel's value is smaller than musl's value on some
// architectures. Thus, although this check may appear
// redundant, it is not.
if (!(ss->ss_flags & SS_DISABLE) && ss->ss_size < MINSIGSTKSZ) {
errno = ENOMEM;
return -1;
}
// Linux ignores SS_ONSTACK on input, but POSIX requires an
// error.
if (ss->ss_flags & SS_ONSTACK) {
errno = EINVAL;
return -1;
}
}
return syscall(SYS_sigaltstack, ss, old);
}
|