summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2024-08-31 12:34:13 -0400
committerRich Felker <dalias@aerifal.cx>2024-08-31 12:38:56 -0400
commit8c43c562694fd0436494dc9d3faabb3eea86f9d8 (patch)
treec47956ef36cc342339d93650ae6939aec4844186 /src
parent300a1f53907a4acaadd9a696d0c67eee6fc10430 (diff)
downloadmusl-8c43c562694fd0436494dc9d3faabb3eea86f9d8.tar.gz
sysconf: fix _SC_MINSIGSTKSZ computation to match kernel interpretation
the value placed in the aux vector AT_MINSIGSTKSZ by the kernel is purely the signal frame size, and does not include any execution space for the signal handler. this is contrary to the POSIX definition of MINSIGSTKSZ to be a value that can actually execute at least some minimal signal handler, and contrary to the historical definitions of MINSIGSTKSZ which had at least 1k of headroom.
Diffstat (limited to 'src')
-rw-r--r--src/conf/sysconf.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/conf/sysconf.c b/src/conf/sysconf.c
index 60d3e745..8dd5c725 100644
--- a/src/conf/sysconf.c
+++ b/src/conf/sysconf.c
@@ -220,8 +220,13 @@ long sysconf(int name)
return (mem > LONG_MAX) ? LONG_MAX : mem;
case JT_MINSIGSTKSZ & 255:
case JT_SIGSTKSZ & 255: ;
- long val = __getauxval(AT_MINSIGSTKSZ);
- if (val < MINSIGSTKSZ) val = MINSIGSTKSZ;
+ /* Value from auxv/kernel is only sigfame size. Clamp it
+ * to at least 1k below arch's traditional MINSIGSTKSZ,
+ * then add 1k of working space for signal handler. */
+ unsigned long sigframe_sz = __getauxval(AT_MINSIGSTKSZ);
+ if (sigframe_sz < MINSIGSTKSZ - 1024)
+ sigframe_sz = MINSIGSTKSZ - 1024;
+ unsigned val = sigframe_sz + 1024;
if (values[name] == JT_SIGSTKSZ)
val += SIGSTKSZ - MINSIGSTKSZ;
return val;