145332b1bSMasahiro Yamadapreferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC)) 245332b1bSMasahiro Yamada 345332b1bSMasahiro Yamadaconfig PLUGIN_HOSTCC 445332b1bSMasahiro Yamada string 5b0441333SKees Cook default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC 645332b1bSMasahiro Yamada help 745332b1bSMasahiro Yamada Host compiler used to build GCC plugins. This can be $(HOSTCXX), 845332b1bSMasahiro Yamada $(HOSTCC), or a null string if GCC plugin is unsupported. 945332b1bSMasahiro Yamada 1045332b1bSMasahiro Yamadaconfig HAVE_GCC_PLUGINS 1145332b1bSMasahiro Yamada bool 1245332b1bSMasahiro Yamada help 1345332b1bSMasahiro Yamada An arch should select this symbol if it supports building with 1445332b1bSMasahiro Yamada GCC plugins. 1545332b1bSMasahiro Yamada 1645332b1bSMasahiro Yamadamenuconfig GCC_PLUGINS 1745332b1bSMasahiro Yamada bool "GCC plugins" 1845332b1bSMasahiro Yamada depends on HAVE_GCC_PLUGINS 1945332b1bSMasahiro Yamada depends on PLUGIN_HOSTCC != "" 2045332b1bSMasahiro Yamada help 2145332b1bSMasahiro Yamada GCC plugins are loadable modules that provide extra features to the 2245332b1bSMasahiro Yamada compiler. They are useful for runtime instrumentation and static analysis. 2345332b1bSMasahiro Yamada 2445332b1bSMasahiro Yamada See Documentation/gcc-plugins.txt for details. 2545332b1bSMasahiro Yamada 2645332b1bSMasahiro Yamadaif GCC_PLUGINS 2745332b1bSMasahiro Yamada 2845332b1bSMasahiro Yamadaconfig GCC_PLUGIN_CYC_COMPLEXITY 2945332b1bSMasahiro Yamada bool "Compute the cyclomatic complexity of a function" if EXPERT 3045332b1bSMasahiro Yamada depends on !COMPILE_TEST # too noisy 3145332b1bSMasahiro Yamada help 3245332b1bSMasahiro Yamada The complexity M of a function's control flow graph is defined as: 3345332b1bSMasahiro Yamada M = E - N + 2P 3445332b1bSMasahiro Yamada where 3545332b1bSMasahiro Yamada 3645332b1bSMasahiro Yamada E = the number of edges 3745332b1bSMasahiro Yamada N = the number of nodes 3845332b1bSMasahiro Yamada P = the number of connected components (exit nodes). 3945332b1bSMasahiro Yamada 4045332b1bSMasahiro Yamada Enabling this plugin reports the complexity to stderr during the 4145332b1bSMasahiro Yamada build. It mainly serves as a simple example of how to create a 4245332b1bSMasahiro Yamada gcc plugin for the kernel. 4345332b1bSMasahiro Yamada 4445332b1bSMasahiro Yamadaconfig GCC_PLUGIN_SANCOV 4545332b1bSMasahiro Yamada bool 4645332b1bSMasahiro Yamada help 4745332b1bSMasahiro Yamada This plugin inserts a __sanitizer_cov_trace_pc() call at the start of 4845332b1bSMasahiro Yamada basic blocks. It supports all gcc versions with plugin support (from 4945332b1bSMasahiro Yamada gcc-4.5 on). It is based on the commit "Add fuzzing coverage support" 5045332b1bSMasahiro Yamada by Dmitry Vyukov <dvyukov@google.com>. 5145332b1bSMasahiro Yamada 5245332b1bSMasahiro Yamadaconfig GCC_PLUGIN_LATENT_ENTROPY 5345332b1bSMasahiro Yamada bool "Generate some entropy during boot and runtime" 5445332b1bSMasahiro Yamada help 5545332b1bSMasahiro Yamada By saying Y here the kernel will instrument some kernel code to 5645332b1bSMasahiro Yamada extract some entropy from both original and artificially created 5745332b1bSMasahiro Yamada program state. This will help especially embedded systems where 5845332b1bSMasahiro Yamada there is little 'natural' source of entropy normally. The cost 5945332b1bSMasahiro Yamada is some slowdown of the boot process (about 0.5%) and fork and 6045332b1bSMasahiro Yamada irq processing. 6145332b1bSMasahiro Yamada 6245332b1bSMasahiro Yamada Note that entropy extracted this way is not cryptographically 6345332b1bSMasahiro Yamada secure! 6445332b1bSMasahiro Yamada 6545332b1bSMasahiro Yamada This plugin was ported from grsecurity/PaX. More information at: 6645332b1bSMasahiro Yamada * https://grsecurity.net/ 6745332b1bSMasahiro Yamada * https://pax.grsecurity.net/ 6845332b1bSMasahiro Yamada 6945332b1bSMasahiro Yamadaconfig GCC_PLUGIN_STRUCTLEAK 7045332b1bSMasahiro Yamada bool "Force initialization of variables containing userspace addresses" 7145332b1bSMasahiro Yamada # Currently STRUCTLEAK inserts initialization out of live scope of 7245332b1bSMasahiro Yamada # variables from KASAN point of view. This leads to KASAN false 7345332b1bSMasahiro Yamada # positive reports. Prohibit this combination for now. 7445332b1bSMasahiro Yamada depends on !KASAN_EXTRA 7545332b1bSMasahiro Yamada help 7645332b1bSMasahiro Yamada This plugin zero-initializes any structures containing a 7745332b1bSMasahiro Yamada __user attribute. This can prevent some classes of information 7845332b1bSMasahiro Yamada exposures. 7945332b1bSMasahiro Yamada 8045332b1bSMasahiro Yamada This plugin was ported from grsecurity/PaX. More information at: 8145332b1bSMasahiro Yamada * https://grsecurity.net/ 8245332b1bSMasahiro Yamada * https://pax.grsecurity.net/ 8345332b1bSMasahiro Yamada 8445332b1bSMasahiro Yamadaconfig GCC_PLUGIN_STRUCTLEAK_BYREF_ALL 8545332b1bSMasahiro Yamada bool "Force initialize all struct type variables passed by reference" 8645332b1bSMasahiro Yamada depends on GCC_PLUGIN_STRUCTLEAK 8745332b1bSMasahiro Yamada depends on !COMPILE_TEST 8845332b1bSMasahiro Yamada help 8945332b1bSMasahiro Yamada Zero initialize any struct type local variable that may be passed by 9045332b1bSMasahiro Yamada reference without having been initialized. 9145332b1bSMasahiro Yamada 9245332b1bSMasahiro Yamadaconfig GCC_PLUGIN_STRUCTLEAK_VERBOSE 9345332b1bSMasahiro Yamada bool "Report forcefully initialized variables" 9445332b1bSMasahiro Yamada depends on GCC_PLUGIN_STRUCTLEAK 9545332b1bSMasahiro Yamada depends on !COMPILE_TEST # too noisy 9645332b1bSMasahiro Yamada help 9745332b1bSMasahiro Yamada This option will cause a warning to be printed each time the 9845332b1bSMasahiro Yamada structleak plugin finds a variable it thinks needs to be 9945332b1bSMasahiro Yamada initialized. Since not all existing initializers are detected 10045332b1bSMasahiro Yamada by the plugin, this can produce false positive warnings. 10145332b1bSMasahiro Yamada 10245332b1bSMasahiro Yamadaconfig GCC_PLUGIN_RANDSTRUCT 10345332b1bSMasahiro Yamada bool "Randomize layout of sensitive kernel structures" 10445332b1bSMasahiro Yamada select MODVERSIONS if MODULES 10545332b1bSMasahiro Yamada help 10645332b1bSMasahiro Yamada If you say Y here, the layouts of structures that are entirely 10745332b1bSMasahiro Yamada function pointers (and have not been manually annotated with 10845332b1bSMasahiro Yamada __no_randomize_layout), or structures that have been explicitly 10945332b1bSMasahiro Yamada marked with __randomize_layout, will be randomized at compile-time. 11045332b1bSMasahiro Yamada This can introduce the requirement of an additional information 11145332b1bSMasahiro Yamada exposure vulnerability for exploits targeting these structure 11245332b1bSMasahiro Yamada types. 11345332b1bSMasahiro Yamada 11445332b1bSMasahiro Yamada Enabling this feature will introduce some performance impact, 11545332b1bSMasahiro Yamada slightly increase memory usage, and prevent the use of forensic 11645332b1bSMasahiro Yamada tools like Volatility against the system (unless the kernel 11745332b1bSMasahiro Yamada source tree isn't cleaned after kernel installation). 11845332b1bSMasahiro Yamada 11945332b1bSMasahiro Yamada The seed used for compilation is located at 12045332b1bSMasahiro Yamada scripts/gcc-plgins/randomize_layout_seed.h. It remains after 12145332b1bSMasahiro Yamada a make clean to allow for external modules to be compiled with 12245332b1bSMasahiro Yamada the existing seed and will be removed by a make mrproper or 12345332b1bSMasahiro Yamada make distclean. 12445332b1bSMasahiro Yamada 12545332b1bSMasahiro Yamada Note that the implementation requires gcc 4.7 or newer. 12645332b1bSMasahiro Yamada 12745332b1bSMasahiro Yamada This plugin was ported from grsecurity/PaX. More information at: 12845332b1bSMasahiro Yamada * https://grsecurity.net/ 12945332b1bSMasahiro Yamada * https://pax.grsecurity.net/ 13045332b1bSMasahiro Yamada 13145332b1bSMasahiro Yamadaconfig GCC_PLUGIN_RANDSTRUCT_PERFORMANCE 13245332b1bSMasahiro Yamada bool "Use cacheline-aware structure randomization" 13345332b1bSMasahiro Yamada depends on GCC_PLUGIN_RANDSTRUCT 13445332b1bSMasahiro Yamada depends on !COMPILE_TEST # do not reduce test coverage 13545332b1bSMasahiro Yamada help 13645332b1bSMasahiro Yamada If you say Y here, the RANDSTRUCT randomization will make a 13745332b1bSMasahiro Yamada best effort at restricting randomization to cacheline-sized 13845332b1bSMasahiro Yamada groups of elements. It will further not randomize bitfields 13945332b1bSMasahiro Yamada in structures. This reduces the performance hit of RANDSTRUCT 14045332b1bSMasahiro Yamada at the cost of weakened randomization. 14145332b1bSMasahiro Yamada 142afaef01cSAlexander Popovconfig GCC_PLUGIN_STACKLEAK 143afaef01cSAlexander Popov bool "Erase the kernel stack before returning from syscalls" 144afaef01cSAlexander Popov depends on GCC_PLUGINS 145afaef01cSAlexander Popov depends on HAVE_ARCH_STACKLEAK 146afaef01cSAlexander Popov help 147afaef01cSAlexander Popov This option makes the kernel erase the kernel stack before 148afaef01cSAlexander Popov returning from system calls. That reduces the information which 149afaef01cSAlexander Popov kernel stack leak bugs can reveal and blocks some uninitialized 150afaef01cSAlexander Popov stack variable attacks. 151afaef01cSAlexander Popov 152afaef01cSAlexander Popov The tradeoff is the performance impact: on a single CPU system kernel 153afaef01cSAlexander Popov compilation sees a 1% slowdown, other systems and workloads may vary 154afaef01cSAlexander Popov and you are advised to test this feature on your expected workload 155afaef01cSAlexander Popov before deploying it. 156afaef01cSAlexander Popov 157afaef01cSAlexander Popov This plugin was ported from grsecurity/PaX. More information at: 158afaef01cSAlexander Popov * https://grsecurity.net/ 159afaef01cSAlexander Popov * https://pax.grsecurity.net/ 160afaef01cSAlexander Popov 16110e9ae9fSAlexander Popovconfig STACKLEAK_TRACK_MIN_SIZE 16210e9ae9fSAlexander Popov int "Minimum stack frame size of functions tracked by STACKLEAK" 16310e9ae9fSAlexander Popov default 100 16410e9ae9fSAlexander Popov range 0 4096 16510e9ae9fSAlexander Popov depends on GCC_PLUGIN_STACKLEAK 16610e9ae9fSAlexander Popov help 16710e9ae9fSAlexander Popov The STACKLEAK gcc plugin instruments the kernel code for tracking 16810e9ae9fSAlexander Popov the lowest border of the kernel stack (and for some other purposes). 16910e9ae9fSAlexander Popov It inserts the stackleak_track_stack() call for the functions with 17010e9ae9fSAlexander Popov a stack frame size greater than or equal to this parameter. 17110e9ae9fSAlexander Popov If unsure, leave the default value 100. 17210e9ae9fSAlexander Popov 173c8d12627SAlexander Popovconfig STACKLEAK_METRICS 174c8d12627SAlexander Popov bool "Show STACKLEAK metrics in the /proc file system" 175c8d12627SAlexander Popov depends on GCC_PLUGIN_STACKLEAK 176c8d12627SAlexander Popov depends on PROC_FS 177c8d12627SAlexander Popov help 178c8d12627SAlexander Popov If this is set, STACKLEAK metrics for every task are available in 179c8d12627SAlexander Popov the /proc file system. In particular, /proc/<pid>/stack_depth 180c8d12627SAlexander Popov shows the maximum kernel stack consumption for the current and 181c8d12627SAlexander Popov previous syscalls. Although this information is not precise, it 182c8d12627SAlexander Popov can be useful for estimating the STACKLEAK performance impact for 183c8d12627SAlexander Popov your workloads. 184c8d12627SAlexander Popov 185964c9dffSAlexander Popovconfig STACKLEAK_RUNTIME_DISABLE 186964c9dffSAlexander Popov bool "Allow runtime disabling of kernel stack erasing" 187964c9dffSAlexander Popov depends on GCC_PLUGIN_STACKLEAK 188964c9dffSAlexander Popov help 189964c9dffSAlexander Popov This option provides 'stack_erasing' sysctl, which can be used in 190964c9dffSAlexander Popov runtime to control kernel stack erasing for kernels built with 191964c9dffSAlexander Popov CONFIG_GCC_PLUGIN_STACKLEAK. 192964c9dffSAlexander Popov 193*189af465SArd Biesheuvelconfig GCC_PLUGIN_ARM_SSP_PER_TASK 194*189af465SArd Biesheuvel bool 195*189af465SArd Biesheuvel depends on GCC_PLUGINS && ARM 196*189af465SArd Biesheuvel 19745332b1bSMasahiro Yamadaendif 198