-fstack-check
: If two feature macros STACK_CHECK_BUILTIN
and STACK_CHECK_STATIC_BUILTIN
are left at the default 0, it just inserts a NULL byte every 4kb (page) when the stack grows.
By default only one, but when the stack can grow more than one page, which is the most dangerous case, every 4KB. linux >2.6 only has only one small page gap between the stack and the heap, which can lead to stack-gap attacks, known since 2005.
See What exception is raised in C by GCC -fstack-check option for assembly.
It is enabled in gcc at least since 2.95.3, in clang since 3.6.
__stack_chk_fail
is the inserted -fstack-protector
code which verifies an inserted stack canary value which might be overwritten by a simple stack overflow, e.g. by recursion.