diff options
author | Rich Felker <dalias@aerifal.cx> | 2024-08-31 12:25:44 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2024-08-31 12:38:56 -0400 |
commit | 300a1f53907a4acaadd9a696d0c67eee6fc10430 (patch) | |
tree | 5e8d305d2433d5c7f4d3eebd284e7132db27c923 | |
parent | 572a2e2eb91f00f2f25d301cfb50f435e7ae16b3 (diff) | |
download | musl-300a1f53907a4acaadd9a696d0c67eee6fc10430.tar.gz musl-300a1f53907a4acaadd9a696d0c67eee6fc10430.tar.xz musl-300a1f53907a4acaadd9a696d0c67eee6fc10430.zip |
sigaltstack: enforce dynamic MINSIGSTKSZ limit
commit 996b6154b20184c3b08cce28eb01edb7f47e9413 added support for querying the dynamic limit but did not enforce it in sigaltstack. the kernel also does not seem to reliably enforce it, or at least does not necessarily enforce the same limit exposed to userspace, so it needs to be enforced here.
-rw-r--r-- | src/signal/sigaltstack.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/signal/sigaltstack.c b/src/signal/sigaltstack.c index d3a6e821..616625c5 100644 --- a/src/signal/sigaltstack.c +++ b/src/signal/sigaltstack.c @@ -1,11 +1,13 @@ #include <signal.h> #include <errno.h> +#include <unistd.h> #include "syscall.h" int sigaltstack(const stack_t *restrict ss, stack_t *restrict old) { if (ss) { - if (!(ss->ss_flags & SS_DISABLE) && ss->ss_size < MINSIGSTKSZ) { + size_t min = sysconf(_SC_MINSIGSTKSZ); + if (!(ss->ss_flags & SS_DISABLE) && ss->ss_size < min) { errno = ENOMEM; return -1; } |