Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect Stack overflows

How do operating systems detect stack overflows of user-space programs [and then send SIGTERM or SIGSEGV to those userspace programs] ?

like image 220
Bandicoot Avatar asked Oct 19 '11 21:10

Bandicoot


1 Answers

Guard pages. When the OS creates the stack for the program it will allocate a little bit more than is specified. The memory is allocated in pages (usually 4KB each), and the extra page will have settings such that any attempt to access it will result in an exception being thrown.

like image 196
James Avatar answered Sep 20 '22 01:09

James