blob: f8ca236d6165ec918e1c5195d64aef677781d1e7 [file] [log] [blame]
Thomas Gleixnerec8f24b2019-05-19 13:07:45 +01001# SPDX-License-Identifier: GPL-2.0-only
Masahiro Yamada45332b12018-07-05 15:24:12 +09002preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))
3
4config PLUGIN_HOSTCC
5 string
Kees Cookb0441332018-08-22 23:02:31 -07006 default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC
Masahiro Yamada45332b12018-07-05 15:24:12 +09007 help
8 Host compiler used to build GCC plugins. This can be $(HOSTCXX),
9 $(HOSTCC), or a null string if GCC plugin is unsupported.
10
11config HAVE_GCC_PLUGINS
12 bool
13 help
14 An arch should select this symbol if it supports building with
15 GCC plugins.
16
Arnd Bergmanna5b0dc52019-12-11 14:39:28 +010017menuconfig GCC_PLUGINS
18 bool "GCC plugins"
Masahiro Yamada45332b12018-07-05 15:24:12 +090019 depends on HAVE_GCC_PLUGINS
20 depends on PLUGIN_HOSTCC != ""
Kees Cook9f671e52019-04-10 08:23:44 -070021 default y
Masahiro Yamada45332b12018-07-05 15:24:12 +090022 help
23 GCC plugins are loadable modules that provide extra features to the
24 compiler. They are useful for runtime instrumentation and static analysis.
25
Jonathan Corbet2b4cbd52020-03-02 15:24:04 -070026 See Documentation/kbuild/gcc-plugins.rst for details.
Masahiro Yamada45332b12018-07-05 15:24:12 +090027
Arnd Bergmanna5b0dc52019-12-11 14:39:28 +010028if GCC_PLUGINS
Masahiro Yamada45332b12018-07-05 15:24:12 +090029
30config GCC_PLUGIN_CYC_COMPLEXITY
31 bool "Compute the cyclomatic complexity of a function" if EXPERT
32 depends on !COMPILE_TEST # too noisy
33 help
34 The complexity M of a function's control flow graph is defined as:
35 M = E - N + 2P
36 where
37
38 E = the number of edges
39 N = the number of nodes
40 P = the number of connected components (exit nodes).
41
42 Enabling this plugin reports the complexity to stderr during the
43 build. It mainly serves as a simple example of how to create a
44 gcc plugin for the kernel.
45
46config GCC_PLUGIN_SANCOV
47 bool
48 help
49 This plugin inserts a __sanitizer_cov_trace_pc() call at the start of
50 basic blocks. It supports all gcc versions with plugin support (from
51 gcc-4.5 on). It is based on the commit "Add fuzzing coverage support"
52 by Dmitry Vyukov <dvyukov@google.com>.
53
54config GCC_PLUGIN_LATENT_ENTROPY
55 bool "Generate some entropy during boot and runtime"
56 help
57 By saying Y here the kernel will instrument some kernel code to
58 extract some entropy from both original and artificially created
59 program state. This will help especially embedded systems where
60 there is little 'natural' source of entropy normally. The cost
61 is some slowdown of the boot process (about 0.5%) and fork and
62 irq processing.
63
64 Note that entropy extracted this way is not cryptographically
65 secure!
66
67 This plugin was ported from grsecurity/PaX. More information at:
68 * https://grsecurity.net/
69 * https://pax.grsecurity.net/
70
Masahiro Yamada45332b12018-07-05 15:24:12 +090071config GCC_PLUGIN_RANDSTRUCT
72 bool "Randomize layout of sensitive kernel structures"
73 select MODVERSIONS if MODULES
74 help
75 If you say Y here, the layouts of structures that are entirely
76 function pointers (and have not been manually annotated with
77 __no_randomize_layout), or structures that have been explicitly
78 marked with __randomize_layout, will be randomized at compile-time.
79 This can introduce the requirement of an additional information
80 exposure vulnerability for exploits targeting these structure
81 types.
82
83 Enabling this feature will introduce some performance impact,
84 slightly increase memory usage, and prevent the use of forensic
85 tools like Volatility against the system (unless the kernel
86 source tree isn't cleaned after kernel installation).
87
88 The seed used for compilation is located at
89 scripts/gcc-plgins/randomize_layout_seed.h. It remains after
90 a make clean to allow for external modules to be compiled with
91 the existing seed and will be removed by a make mrproper or
92 make distclean.
93
94 Note that the implementation requires gcc 4.7 or newer.
95
96 This plugin was ported from grsecurity/PaX. More information at:
97 * https://grsecurity.net/
98 * https://pax.grsecurity.net/
99
100config GCC_PLUGIN_RANDSTRUCT_PERFORMANCE
101 bool "Use cacheline-aware structure randomization"
102 depends on GCC_PLUGIN_RANDSTRUCT
103 depends on !COMPILE_TEST # do not reduce test coverage
104 help
105 If you say Y here, the RANDSTRUCT randomization will make a
106 best effort at restricting randomization to cacheline-sized
107 groups of elements. It will further not randomize bitfields
108 in structures. This reduces the performance hit of RANDSTRUCT
109 at the cost of weakened randomization.
110
Ard Biesheuvel189af462018-12-06 09:32:57 +0100111config GCC_PLUGIN_ARM_SSP_PER_TASK
112 bool
113 depends on GCC_PLUGINS && ARM
114
Arnd Bergmanna5b0dc52019-12-11 14:39:28 +0100115endif