Author: Peter Smith Date: 2020-08-06T13:47:21+01:00 New Revision: 839d974ee0e45f09b9665b4eed734ca1ba174d25
URL: https://github.com/llvm/llvm-project/commit/839d974ee0e45f09b9665b4eed734ca1ba174d25 DIFF: https://github.com/llvm/llvm-project/commit/839d974ee0e45f09b9665b4eed734ca1ba174d25.diff LOG: [DOCS] Add more detail to stack protector documentation The Clang -fstack-protector documentation mentions what functions are considered vulnerable but does not mention the details of the implementation such as the use of a global variable for the guard value. This brings the documentation more in line with the GCC documentation at: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html and gives someone using the option more idea about what is protected. This partly addresses https://bugs.llvm.org/show_bug.cgi?id=42764 Differential Revision: https://reviews.llvm.org/D85239 Added: Modified: clang/docs/ClangCommandLineReference.rst clang/include/clang/Driver/Options.td Removed: ################################################################################ diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst index 8eb010eae265..4caa08a82a72 100644 --- a/clang/docs/ClangCommandLineReference.rst +++ b/clang/docs/ClangCommandLineReference.rst @@ -2136,7 +2136,7 @@ Enable stack clash protection .. option:: -fstack-protector, -fno-stack-protector -Enable stack protectors for some functions vulnerable to stack smashing. This uses a loose heuristic which considers functions vulnerable if they contain a char (or 8bit integer) array or constant sized calls to alloca, which are of greater size than ssp-buffer-size (default: 8 bytes). All variable sized calls to alloca are considered vulnerable +Enable stack protectors for some functions vulnerable to stack smashing. This uses a loose heuristic which considers functions vulnerable if they contain a char (or 8bit integer) array or constant sized calls to alloca , which are of greater size than ssp-buffer-size (default: 8 bytes). All variable sized calls to alloca are considered vulnerable. A function witha stack protector has a guard value added to the stack frame that is checked on function exit. The guard value must be positioned in the stack frame such that a buffer overflow from a vulnerable variable will overwrite the guard value before overwriting the function's return address. The reference stack guard value is stored in a global variable. .. option:: -fstack-protector-all diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 786a3c362842..fc31c23e4240 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1801,10 +1801,15 @@ def fstack_protector_strong : Flag<["-"], "fstack-protector-strong">, Group<f_Gr "as well as any calls to alloca or the taking of an address from a local variable">; def fstack_protector : Flag<["-"], "fstack-protector">, Group<f_Group>, HelpText<"Enable stack protectors for some functions vulnerable to stack smashing. " - "This uses a loose heuristic which considers functions vulnerable " - "if they contain a char (or 8bit integer) array or constant sized calls to " - "alloca, which are of greater size than ssp-buffer-size (default: 8 bytes). " - "All variable sized calls to alloca are considered vulnerable">; + "This uses a loose heuristic which considers functions vulnerable if they " + "contain a char (or 8bit integer) array or constant sized calls to alloca " + ", which are of greater size than ssp-buffer-size (default: 8 bytes). All " + "variable sized calls to alloca are considered vulnerable. A function with" + "a stack protector has a guard value added to the stack frame that is " + "checked on function exit. The guard value must be positioned in the " + "stack frame such that a buffer overflow from a vulnerable variable will " + "overwrite the guard value before overwriting the function's return " + "address. The reference stack guard value is stored in a global variable.">; def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack variables: uninitialized (default)" " | pattern">, Values<"uninitialized,pattern">; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits