IT lexicon › Security › Stack clash protection

Stack clash protection

Security På svenska → Updated: 2026-11-05

The compiler touches every page as a large stack frame is allocated, so the stack can't leap over the guard page and land in someone else's memory.

Below the stack sits an unmapped guard page meant to crash the program if the stack grows too far. But a function that drops the stack pointer by a megabyte in one go — a big local array, an alloca — simply steps over it. Qualys showed in 2017 that this could be exploited to make the stack write into the heap or into shared libraries, and named it Stack Clash.

The fix is stack probing: the prologue allocates one page at a time and writes to each, guaranteeing the guard page gets hit. GCC 8 gained -fstack-clash-protection in 2018, and Clang followed for x86 in version 11. Windows has required the same thing in its ABI for decades — __chkstk is called for any frame larger than a page — which makes Linux's late arrival slightly embarrassing.

← Back to the lexicon