2 ms·
Yes, that’s correct. For example, if the stack grows downwards (which, AFAIK, is the case on most current architectures): - stack pointer is at S - protected
by Someone 8y ago
Yes, that’s correct. For example, if the stack grows downwards (which, AFAIK, is the case on most current architectures):
- stack pointer is at S
- protected area starts at B, ends at E (with B<E<S)
- stack is decreased by something larger than (S-B), making it point somewhere before the start of the protected area
Compilers won’t allocate large local variables on the stack, so guard pages work fine for accidental stack overflows, such as when a call stack gets too deep. They also work reasonably well against intentional (by an attacker, not by the programmer who wrote the code) ones, but indeed aren’t perfect. That’s why some compilers have compiler flags that, when allocating a stack variable that they don’t know to be ‘small’ will insert extra code that will hit the protected area, even if the allocation jumps over it.