RFC: Update MINSIGSTKSZ and SIGSTKSZ
H.J. Lu
hjl.tools@gmail.com
Tue Sep 29 13:26:27 GMT 2020
Since www.openwall.com is down and I can't subscribe to the libc-coord list, I
post it here.
MINSIGSTKSZ and SIGSTKSZ were defined as constant:
/* Minimum stack size for a signal handler. */
#define MINSIGSTKSZ 2048
/* System default stack size. */
#define SIGSTKSZ 8192
more than 20 years ago. For today's processors, they are too small:
https://sourceware.org/bugzilla/show_bug.cgi?id=20305
I am proposing to make them as dynamic based on AT_MINSIGSTKSZ for
-D_GNU_SOURCE:
extern int getminsigstacksize (void);
#ifdef __USE_GNU
/* Minumum stack size for a signal handler: AT_MINSIGSTKSZ + 1.5KB. */
# undef MINSIGSTKSZ
# define MINSIGSTKSZ (getminsigstacksize () + 1536)
/* System default stack size for a signal handler: MINSIGSTKSZ + 6KB. */
# undef SIGSTKSZ
# define SIGSTKSZ (MINSIGSTKSZ + 6144)
#endif
On x86, we can emulate AT_MINSIGSTKSZ if kernel doesn't provide it:
/* Emulate AT_MINSIGSTKSZ. In Linux kernel, the signal frame data
with XSAVE is composed of the following areas and laid out as:
------------------------------
| alignment padding |
------------------------------
| xsave buffer |
------------------------------
| fsave header (32-bit only) |
------------------------------
| siginfo + ucontext |
------------------------------
*/
It works for most usages, except for
static char stack[MINSIGSTKSZ];
--
H.J.
More information about the Libc-alpha
mailing list