1*45332b1bSMasahiro Yamadapreferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC)) 2*45332b1bSMasahiro Yamada 3*45332b1bSMasahiro Yamadaconfig PLUGIN_HOSTCC 4*45332b1bSMasahiro Yamada string 5*45332b1bSMasahiro Yamada default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" 6*45332b1bSMasahiro Yamada help 7*45332b1bSMasahiro Yamada Host compiler used to build GCC plugins. This can be $(HOSTCXX), 8*45332b1bSMasahiro Yamada $(HOSTCC), or a null string if GCC plugin is unsupported. 9*45332b1bSMasahiro Yamada 10*45332b1bSMasahiro Yamadaconfig HAVE_GCC_PLUGINS 11*45332b1bSMasahiro Yamada bool 12*45332b1bSMasahiro Yamada help 13*45332b1bSMasahiro Yamada An arch should select this symbol if it supports building with 14*45332b1bSMasahiro Yamada GCC plugins. 15*45332b1bSMasahiro Yamada 16*45332b1bSMasahiro Yamadamenuconfig GCC_PLUGINS 17*45332b1bSMasahiro Yamada bool "GCC plugins" 18*45332b1bSMasahiro Yamada depends on HAVE_GCC_PLUGINS 19*45332b1bSMasahiro Yamada depends on PLUGIN_HOSTCC != "" 20*45332b1bSMasahiro Yamada help 21*45332b1bSMasahiro Yamada GCC plugins are loadable modules that provide extra features to the 22*45332b1bSMasahiro Yamada compiler. They are useful for runtime instrumentation and static analysis. 23*45332b1bSMasahiro Yamada 24*45332b1bSMasahiro Yamada See Documentation/gcc-plugins.txt for details. 25*45332b1bSMasahiro Yamada 26*45332b1bSMasahiro Yamadaif GCC_PLUGINS 27*45332b1bSMasahiro Yamada 28*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_CYC_COMPLEXITY 29*45332b1bSMasahiro Yamada bool "Compute the cyclomatic complexity of a function" if EXPERT 30*45332b1bSMasahiro Yamada depends on !COMPILE_TEST # too noisy 31*45332b1bSMasahiro Yamada help 32*45332b1bSMasahiro Yamada The complexity M of a function's control flow graph is defined as: 33*45332b1bSMasahiro Yamada M = E - N + 2P 34*45332b1bSMasahiro Yamada where 35*45332b1bSMasahiro Yamada 36*45332b1bSMasahiro Yamada E = the number of edges 37*45332b1bSMasahiro Yamada N = the number of nodes 38*45332b1bSMasahiro Yamada P = the number of connected components (exit nodes). 39*45332b1bSMasahiro Yamada 40*45332b1bSMasahiro Yamada Enabling this plugin reports the complexity to stderr during the 41*45332b1bSMasahiro Yamada build. It mainly serves as a simple example of how to create a 42*45332b1bSMasahiro Yamada gcc plugin for the kernel. 43*45332b1bSMasahiro Yamada 44*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_SANCOV 45*45332b1bSMasahiro Yamada bool 46*45332b1bSMasahiro Yamada help 47*45332b1bSMasahiro Yamada This plugin inserts a __sanitizer_cov_trace_pc() call at the start of 48*45332b1bSMasahiro Yamada basic blocks. It supports all gcc versions with plugin support (from 49*45332b1bSMasahiro Yamada gcc-4.5 on). It is based on the commit "Add fuzzing coverage support" 50*45332b1bSMasahiro Yamada by Dmitry Vyukov <dvyukov@google.com>. 51*45332b1bSMasahiro Yamada 52*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_LATENT_ENTROPY 53*45332b1bSMasahiro Yamada bool "Generate some entropy during boot and runtime" 54*45332b1bSMasahiro Yamada help 55*45332b1bSMasahiro Yamada By saying Y here the kernel will instrument some kernel code to 56*45332b1bSMasahiro Yamada extract some entropy from both original and artificially created 57*45332b1bSMasahiro Yamada program state. This will help especially embedded systems where 58*45332b1bSMasahiro Yamada there is little 'natural' source of entropy normally. The cost 59*45332b1bSMasahiro Yamada is some slowdown of the boot process (about 0.5%) and fork and 60*45332b1bSMasahiro Yamada irq processing. 61*45332b1bSMasahiro Yamada 62*45332b1bSMasahiro Yamada Note that entropy extracted this way is not cryptographically 63*45332b1bSMasahiro Yamada secure! 64*45332b1bSMasahiro Yamada 65*45332b1bSMasahiro Yamada This plugin was ported from grsecurity/PaX. More information at: 66*45332b1bSMasahiro Yamada * https://grsecurity.net/ 67*45332b1bSMasahiro Yamada * https://pax.grsecurity.net/ 68*45332b1bSMasahiro Yamada 69*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_STRUCTLEAK 70*45332b1bSMasahiro Yamada bool "Force initialization of variables containing userspace addresses" 71*45332b1bSMasahiro Yamada # Currently STRUCTLEAK inserts initialization out of live scope of 72*45332b1bSMasahiro Yamada # variables from KASAN point of view. This leads to KASAN false 73*45332b1bSMasahiro Yamada # positive reports. Prohibit this combination for now. 74*45332b1bSMasahiro Yamada depends on !KASAN_EXTRA 75*45332b1bSMasahiro Yamada help 76*45332b1bSMasahiro Yamada This plugin zero-initializes any structures containing a 77*45332b1bSMasahiro Yamada __user attribute. This can prevent some classes of information 78*45332b1bSMasahiro Yamada exposures. 79*45332b1bSMasahiro Yamada 80*45332b1bSMasahiro Yamada This plugin was ported from grsecurity/PaX. More information at: 81*45332b1bSMasahiro Yamada * https://grsecurity.net/ 82*45332b1bSMasahiro Yamada * https://pax.grsecurity.net/ 83*45332b1bSMasahiro Yamada 84*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_STRUCTLEAK_BYREF_ALL 85*45332b1bSMasahiro Yamada bool "Force initialize all struct type variables passed by reference" 86*45332b1bSMasahiro Yamada depends on GCC_PLUGIN_STRUCTLEAK 87*45332b1bSMasahiro Yamada depends on !COMPILE_TEST 88*45332b1bSMasahiro Yamada help 89*45332b1bSMasahiro Yamada Zero initialize any struct type local variable that may be passed by 90*45332b1bSMasahiro Yamada reference without having been initialized. 91*45332b1bSMasahiro Yamada 92*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_STRUCTLEAK_VERBOSE 93*45332b1bSMasahiro Yamada bool "Report forcefully initialized variables" 94*45332b1bSMasahiro Yamada depends on GCC_PLUGIN_STRUCTLEAK 95*45332b1bSMasahiro Yamada depends on !COMPILE_TEST # too noisy 96*45332b1bSMasahiro Yamada help 97*45332b1bSMasahiro Yamada This option will cause a warning to be printed each time the 98*45332b1bSMasahiro Yamada structleak plugin finds a variable it thinks needs to be 99*45332b1bSMasahiro Yamada initialized. Since not all existing initializers are detected 100*45332b1bSMasahiro Yamada by the plugin, this can produce false positive warnings. 101*45332b1bSMasahiro Yamada 102*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_RANDSTRUCT 103*45332b1bSMasahiro Yamada bool "Randomize layout of sensitive kernel structures" 104*45332b1bSMasahiro Yamada select MODVERSIONS if MODULES 105*45332b1bSMasahiro Yamada help 106*45332b1bSMasahiro Yamada If you say Y here, the layouts of structures that are entirely 107*45332b1bSMasahiro Yamada function pointers (and have not been manually annotated with 108*45332b1bSMasahiro Yamada __no_randomize_layout), or structures that have been explicitly 109*45332b1bSMasahiro Yamada marked with __randomize_layout, will be randomized at compile-time. 110*45332b1bSMasahiro Yamada This can introduce the requirement of an additional information 111*45332b1bSMasahiro Yamada exposure vulnerability for exploits targeting these structure 112*45332b1bSMasahiro Yamada types. 113*45332b1bSMasahiro Yamada 114*45332b1bSMasahiro Yamada Enabling this feature will introduce some performance impact, 115*45332b1bSMasahiro Yamada slightly increase memory usage, and prevent the use of forensic 116*45332b1bSMasahiro Yamada tools like Volatility against the system (unless the kernel 117*45332b1bSMasahiro Yamada source tree isn't cleaned after kernel installation). 118*45332b1bSMasahiro Yamada 119*45332b1bSMasahiro Yamada The seed used for compilation is located at 120*45332b1bSMasahiro Yamada scripts/gcc-plgins/randomize_layout_seed.h. It remains after 121*45332b1bSMasahiro Yamada a make clean to allow for external modules to be compiled with 122*45332b1bSMasahiro Yamada the existing seed and will be removed by a make mrproper or 123*45332b1bSMasahiro Yamada make distclean. 124*45332b1bSMasahiro Yamada 125*45332b1bSMasahiro Yamada Note that the implementation requires gcc 4.7 or newer. 126*45332b1bSMasahiro Yamada 127*45332b1bSMasahiro Yamada This plugin was ported from grsecurity/PaX. More information at: 128*45332b1bSMasahiro Yamada * https://grsecurity.net/ 129*45332b1bSMasahiro Yamada * https://pax.grsecurity.net/ 130*45332b1bSMasahiro Yamada 131*45332b1bSMasahiro Yamadaconfig GCC_PLUGIN_RANDSTRUCT_PERFORMANCE 132*45332b1bSMasahiro Yamada bool "Use cacheline-aware structure randomization" 133*45332b1bSMasahiro Yamada depends on GCC_PLUGIN_RANDSTRUCT 134*45332b1bSMasahiro Yamada depends on !COMPILE_TEST # do not reduce test coverage 135*45332b1bSMasahiro Yamada help 136*45332b1bSMasahiro Yamada If you say Y here, the RANDSTRUCT randomization will make a 137*45332b1bSMasahiro Yamada best effort at restricting randomization to cacheline-sized 138*45332b1bSMasahiro Yamada groups of elements. It will further not randomize bitfields 139*45332b1bSMasahiro Yamada in structures. This reduces the performance hit of RANDSTRUCT 140*45332b1bSMasahiro Yamada at the cost of weakened randomization. 141*45332b1bSMasahiro Yamada 142*45332b1bSMasahiro Yamadaendif 143