Improve alloca() memory safety

Now that all the bugs have been wormed out of the ASAN memory module we
can successfully check for underruns on large stack allocations.
This commit is contained in:
Justine Tunney 2022-04-01 22:44:43 -07:00
parent 1ff1854107
commit 38cb6e71ca
4 changed files with 10 additions and 13 deletions

View file

@ -1121,18 +1121,18 @@ faulthandler_fatal_error_py(PyObject *self, PyObject *args)
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)
#define FAULTHANDLER_STACK_OVERFLOW
static
static dontinline
uintptr_t
stack_overflow(uintptr_t min_sp, uintptr_t max_sp, size_t *depth)
{
/* allocate 4096 bytes on the stack at each call */
unsigned char buffer[4096];
unsigned char buffer[3500]; // [jart] or not
uintptr_t sp = (uintptr_t)&buffer;
*depth += 1;
if (sp < min_sp || max_sp < sp)
return sp;
buffer[0] = 1;
buffer[4095] = 0;
buffer[3500-1] = 0;
return stack_overflow(min_sp, max_sp, depth);
}