Bug 20305 - x86: MINSIGSTKSZ too small for AVX-512F support
Summary: x86: MINSIGSTKSZ too small for AVX-512F support
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: 2.33
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2016-06-28 11:32 UTC by Florian Weimer
Modified: 2020-09-26 12:40 UTC (History)
3 users (show)

See Also:
Target: x86_64, i686
Last reconfirmed:
fweimer: security-

tst-minsigstksz.c (617 bytes, text/plain)
2016-06-28 11:32 UTC, Florian Weimer

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2016-06-28 11:32:46 UTC
Created attachment 9368 [details]

The attached test case fails on a system with AVX512 support (both hardware and kernel) with the following error:

tst-minsigstksz: changed byte 1376 bytes below configured stack
Comment 1 Florian Weimer 2016-06-28 11:35:59 UTC
As a possible fix, the kernel could refuse to save FPU state to the signal handler stack if the specified stack is not large enough.

I do not see a good way to fix this in glibc.  Increasing MINSIGSTKSZ has potential impact on ABI.
Comment 2 Florian Weimer 2016-08-22 15:02:39 UTC
I filed a kernel bug: https://bugzilla.kernel.org/show_bug.cgi?id=153531
Comment 3 Florian Weimer 2020-06-23 13:15:28 UTC
Not surprisingly, this issue happens with 32-bit glibc builds, too.
Comment 4 H.J. Lu 2020-09-25 22:51:48 UTC
MINSIGSTKSZ is defined in <bits/sigstack.h>.  Changing it in the kernel
doesn't help.  However, for AT_MINSIGSTKSZ kernel, we can do

extern int getminsigstacksize (void);

#ifdef __USE_GNU
/* Minumum stack size for a signal handler.  */
# define MINSIGSTKSZ (getminsigstacksize ())
Comment 5 Andreas Schwab 2020-09-26 06:18:24 UTC
MINSIGSTKSZ is required to be a constant.
Comment 6 H.J. Lu 2020-09-26 12:40:34 UTC
(In reply to Andreas Schwab from comment #5)
> MINSIGSTKSZ is required to be a constant.

True.  But this requirement is very old at the time a fixed signal stack
size was sufficient. We can define MINSIGSTKSZ as a function return
under -D_GNU_SOURCE or other macro.