https://github.com/torvalds/linux/blob/84df9525b0c27f3ebc2eb...
https://github.com/torvalds/linux/blob/84df9525b0c27f3ebc2eb...
The stack isn't for bulk storage, I thought that was common knowledge.
Basically the way a kernel detects stack growth is via a guard page that causes a fault on memory access. If the allocation is bigger than the offset to the guard page, and the start of the allocation is accessed before the end, you get this. An attacker might even be able to generate a non-faulting memory access pointing at somebody else's buffer.
I think it's on the language implementation to understand what that offset might be and generate benign memory access on large stack allocations, allowing the kernel to fault and intervene. Consider it part of the ABI where you're running.
But IMO a compiler should generate extra benign reads on a large stack allocation. You mention avoiding VLAs in the kernel, but even user mode code has this problem.
Certainly a browser JITing random JS from the internet should be able to work around such a problem.