GNU Compiler Collection (GCC) Stack-smashing protection was first implemented by
StackGuard in 1997, and published at the 1998
USENIX Security Symposium. StackGuard was introduced as a set of patches to the Intel x86 backend of
GCC 2.7. StackGuard was maintained for the
Immunix Linux distribution from 1998 to 2003, and was extended with implementations for terminator, random and random XOR canaries. StackGuard was suggested for inclusion in GCC 3.x at the GCC 2003 Summit Proceedings, but this was never achieved. From 2001 to 2005,
IBM developed GCC patches for stack-smashing protection, known as
ProPolice. It improved on the idea of StackGuard by placing buffers after local pointers and function arguments in the stack frame. This helped avoid the corruption of pointers, preventing access to arbitrary memory locations.
Red Hat engineers identified problems with ProPolice though, and in 2005 re-implemented stack-smashing protection for inclusion in GCC 4.1. This work introduced the -fstack-protector flag, which protects only some vulnerable functions, and the -fstack-protector-all flag, which protects all functions whether they need it or not. In 2012,
Google engineers implemented the -fstack-protector-strong flag to strike a better balance between security and performance. This flag protects more kinds of vulnerable functions than -fstack-protector does, but not every function, providing better performance than -fstack-protector-all. It is available in GCC since its version 4.9. All
Fedora packages are compiled with -fstack-protector since Fedora Core 5, and -fstack-protector-strong since Fedora 20. Most packages in
Ubuntu are compiled with -fstack-protector since 6.10. Every
Arch Linux package is compiled with -fstack-protector since 2011. All Arch Linux packages built since 4 May 2014 use -fstack-protector-strong. Stack protection is only used for some packages in
Debian, and only for the
FreeBSD base system since 8.0. Stack protection is standard in certain operating systems, including
OpenBSD,
Hardened Gentoo and
DragonFly BSD. StackGuard and ProPolice cannot protect against overflows in automatically allocated structures that overflow into function pointers. ProPolice at least will rearrange the allocation order to get such structures allocated before function pointers. A separate mechanism for
pointer protection was proposed in PointGuard and is available on
Microsoft Windows.
Microsoft Visual Studio The compiler suite from Microsoft implements buffer overflow protection since version 2003 through the command-line switch, which is enabled by default since version 2005. Using disables the protection.
IBM Compiler Stack-smashing protection can be turned on by the compiler flag -qstackprotect. ===Clang/
LLVM=== Clang supports the same -fstack-protector options as GCC and a stronger "safe stack" () system with similarly low performance impact. Clang also has three buffer overflow detectors, namely
AddressSanitizer (-fsanitize=address), and the unofficial SafeCode (last updated for LLVM 3.0). These systems have different tradeoffs in terms of performance penalty, memory overhead, and classes of detected bugs. Stack protection is standard in certain operating systems, including
OpenBSD.
Intel Compiler Intel's C and C++ compiler supports stack-smashing protection with options similar to those provided by GCC and Microsoft Visual Studio.
Fail-Safe C Fail-Safe C StackGhost (hardware-based) Invented by
Mike Frantzen, StackGhost is a simple tweak to the
register window spill–fill routines which makes buffer overflows much more difficult to exploit. It uses a unique hardware feature of the
Sun Microsystems SPARC architecture—deferred,
on-stack,
in-frame register-window
spill and fill—to transparently detect modifications of return
pointers (a common way for an
exploit to hijack execution paths), automatically protecting all applications without requiring their
executable or source-code files to be modified for that. The performance impact is negligible: less than one percent. The resulting
gdb issues were resolved by
Mark Kettenis two years later, allowing enabling of the feature. Following this event, the StackGhost code was integrated (and optimized) into the SPARC version of the
OpenBSD operating system. ==See also==