From 716ab22ae9613a65bf5b4df73474fa2ffc748995 Mon Sep 17 00:00:00 2001 From: James Y Knight Date: Thu, 11 Jul 2019 11:48:08 -0400 Subject: [PATCH] Fix the use of sigaltstack to return to the saved main stack. Previously, musl would reject the call with -ENOMEM, because the main stack typically has ss_size == 0 and ss_flags == SS_DISABLE. Note -- it may seem that the check against MINSIGSTKSZ is redundant, as Linux also checks against MINSIGSTKSZ within the syscall. However, that is not the case, because on some platforms, Musl has set different (larger) values for MINSIGSTKSZ than the kernel. --- src/signal/sigaltstack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/signal/sigaltstack.c b/src/signal/sigaltstack.c index cfa3f5c1..d3a6e821 100644 --- a/src/signal/sigaltstack.c +++ b/src/signal/sigaltstack.c @@ -5,7 +5,7 @@ int sigaltstack(const stack_t *restrict ss, stack_t *restrict old) { if (ss) { - if (ss->ss_size < MINSIGSTKSZ) { + if (!(ss->ss_flags & SS_DISABLE) && ss->ss_size < MINSIGSTKSZ) { errno = ENOMEM; return -1; } -- 2.22.0.410.gd8fdbe21b5-goog