The address space is set up in stupid way, if you let the mmap allocator choose where to allocate. The stack (fixed-size) is at the end of the address space. mmap prefers to return pages that are immediately under this. So if you have a stack overflow, it is possible that the entire heap is overwritten by the stack before the stack accesses finally segfault. Or ever more fun, you could stop recursing after overwriting part of the memory below the stack and then keep executing with corrupt data.
There should be a PROT_NONE region under the stack so stack overflow segfaults normally.
The address space is set up in stupid way, if you let the mmap allocator choose where to allocate. The stack (fixed-size) is at the end of the address space. mmap prefers to return pages that are immediately under this. So if you have a stack overflow, it is possible that the entire heap is overwritten by the stack before the stack accesses finally segfault. Or ever more fun, you could stop recursing after overwriting part of the memory below the stack and then keep executing with corrupt data.
There should be a PROT_NONE region under the stack so stack overflow segfaults normally.