]> git.ipfire.org Git - people/arne_f/kernel.git/blobdiff - arch/Kconfig
stackprotector: Introduce CONFIG_CC_STACKPROTECTOR_STRONG
[people/arne_f/kernel.git] / arch / Kconfig
index 24e026d83072bae1b5e813700fd39af572304d5b..80bbb8ccd0d10b319d932d1be08a2d742f957cfa 100644 (file)
@@ -344,10 +344,17 @@ config HAVE_CC_STACKPROTECTOR
          - it has implemented a stack canary (e.g. __stack_chk_guard)
 
 config CC_STACKPROTECTOR
-       bool "Enable -fstack-protector buffer overflow detection"
+       def_bool n
+       help
+         Set when a stack-protector mode is enabled, so that the build
+         can enable kernel-side support for the GCC feature.
+
+choice
+       prompt "Stack Protector buffer overflow detection"
        depends on HAVE_CC_STACKPROTECTOR
+       default CC_STACKPROTECTOR_NONE
        help
-         This option turns on the -fstack-protector GCC feature. This
+         This option turns on the "stack-protector" GCC feature. This
          feature puts, at the beginning of functions, a canary value on
          the stack just before the return address, and validates
          the value just before actually returning.  Stack based buffer
@@ -355,8 +362,46 @@ config CC_STACKPROTECTOR
          overwrite the canary, which gets detected and the attack is then
          neutralized via a kernel panic.
 
+config CC_STACKPROTECTOR_NONE
+       bool "None"
+       help
+         Disable "stack-protector" GCC feature.
+
+config CC_STACKPROTECTOR_REGULAR
+       bool "Regular"
+       select CC_STACKPROTECTOR
+       help
+         Functions will have the stack-protector canary logic added if they
+         have an 8-byte or larger character array on the stack.
+
          This feature requires gcc version 4.2 or above, or a distribution
-         gcc with the feature backported.
+         gcc with the feature backported ("-fstack-protector").
+
+         On an x86 "defconfig" build, this feature adds canary checks to
+         about 3% of all kernel functions, which increases kernel code size
+         by about 0.3%.
+
+config CC_STACKPROTECTOR_STRONG
+       bool "Strong"
+       select CC_STACKPROTECTOR
+       help
+         Functions will have the stack-protector canary logic added in any
+         of the following conditions:
+
+         - local variable's address used as part of the right hand side of an
+           assignment or function argument
+         - local variable is an array (or union containing an array),
+           regardless of array type or length
+         - uses register local variables
+
+         This feature requires gcc version 4.9 or above, or a distribution
+         gcc with the feature backported ("-fstack-protector-strong").
+
+         On an x86 "defconfig" build, this feature adds canary checks to
+         about 20% of all kernel functions, which increases the kernel code
+         size by about 2%.
+
+endchoice
 
 config HAVE_CONTEXT_TRACKING
        bool