stackprotector
Stackprotector is a security feature in some compilers, notably GCC and Clang, designed to mitigate stack buffer overflow vulnerabilities. It works by placing a secret value, known as a canary or guard, on the stack before any local variables. This canary is typically a pseudo-randomly generated number. When a function returns, the program checks if the canary value on the stack has been modified. If the canary has been altered, it indicates that a buffer overflow may have occurred, overwriting the canary along with other stack data. The program can then terminate safely, preventing an attacker from exploiting the overflow to execute arbitrary code.
The implementation details of stack protection can vary. The canary is usually placed between local variables