~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/security/Kconfig.hardening

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /security/Kconfig.hardening (Version linux-6.12-rc7) and /security/Kconfig.hardening (Version linux-5.19.17)


  1 # SPDX-License-Identifier: GPL-2.0-only             1 # SPDX-License-Identifier: GPL-2.0-only
  2 menu "Kernel hardening options"                     2 menu "Kernel hardening options"
  3                                                     3 
  4 config GCC_PLUGIN_STRUCTLEAK                        4 config GCC_PLUGIN_STRUCTLEAK
  5         bool                                        5         bool
  6         help                                        6         help
  7           While the kernel is built with warni      7           While the kernel is built with warnings enabled for any missed
  8           stack variable initializations, this      8           stack variable initializations, this warning is silenced for
  9           anything passed by reference to anot      9           anything passed by reference to another function, under the
 10           occasionally misguided assumption th     10           occasionally misguided assumption that the function will do
 11           the initialization. As this regularl     11           the initialization. As this regularly leads to exploitable
 12           flaws, this plugin is available to i     12           flaws, this plugin is available to identify and zero-initialize
 13           such variables, depending on the cho     13           such variables, depending on the chosen level of coverage.
 14                                                    14 
 15           This plugin was originally ported fr     15           This plugin was originally ported from grsecurity/PaX. More
 16           information at:                          16           information at:
 17            * https://grsecurity.net/               17            * https://grsecurity.net/
 18            * https://pax.grsecurity.net/           18            * https://pax.grsecurity.net/
 19                                                    19 
 20 menu "Memory initialization"                       20 menu "Memory initialization"
 21                                                    21 
 22 config CC_HAS_AUTO_VAR_INIT_PATTERN                22 config CC_HAS_AUTO_VAR_INIT_PATTERN
 23         def_bool $(cc-option,-ftrivial-auto-va     23         def_bool $(cc-option,-ftrivial-auto-var-init=pattern)
 24                                                    24 
 25 config CC_HAS_AUTO_VAR_INIT_ZERO_BARE              25 config CC_HAS_AUTO_VAR_INIT_ZERO_BARE
 26         def_bool $(cc-option,-ftrivial-auto-va     26         def_bool $(cc-option,-ftrivial-auto-var-init=zero)
 27                                                    27 
 28 config CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER           28 config CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER
 29         # Clang 16 and later warn about using      29         # Clang 16 and later warn about using the -enable flag, but it
 30         # is required before then.                 30         # is required before then.
 31         def_bool $(cc-option,-ftrivial-auto-va     31         def_bool $(cc-option,-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang)
 32         depends on !CC_HAS_AUTO_VAR_INIT_ZERO_     32         depends on !CC_HAS_AUTO_VAR_INIT_ZERO_BARE
 33                                                    33 
 34 config CC_HAS_AUTO_VAR_INIT_ZERO                   34 config CC_HAS_AUTO_VAR_INIT_ZERO
 35         def_bool CC_HAS_AUTO_VAR_INIT_ZERO_BAR     35         def_bool CC_HAS_AUTO_VAR_INIT_ZERO_BARE || CC_HAS_AUTO_VAR_INIT_ZERO_ENABLER
 36                                                    36 
 37 choice                                             37 choice
 38         prompt "Initialize kernel stack variab     38         prompt "Initialize kernel stack variables at function entry"
 39         default GCC_PLUGIN_STRUCTLEAK_BYREF_AL     39         default GCC_PLUGIN_STRUCTLEAK_BYREF_ALL if COMPILE_TEST && GCC_PLUGINS
 40         default INIT_STACK_ALL_PATTERN if COMP     40         default INIT_STACK_ALL_PATTERN if COMPILE_TEST && CC_HAS_AUTO_VAR_INIT_PATTERN
 41         default INIT_STACK_ALL_ZERO if CC_HAS_     41         default INIT_STACK_ALL_ZERO if CC_HAS_AUTO_VAR_INIT_ZERO
 42         default INIT_STACK_NONE                    42         default INIT_STACK_NONE
 43         help                                       43         help
 44           This option enables initialization o     44           This option enables initialization of stack variables at
 45           function entry time. This has the po     45           function entry time. This has the possibility to have the
 46           greatest coverage (since all functio     46           greatest coverage (since all functions can have their
 47           variables initialized), but the perf     47           variables initialized), but the performance impact depends
 48           on the function calling complexity o     48           on the function calling complexity of a given workload's
 49           syscalls.                                49           syscalls.
 50                                                    50 
 51           This chooses the level of coverage o     51           This chooses the level of coverage over classes of potentially
 52           uninitialized variables. The selecte     52           uninitialized variables. The selected class of variable will be
 53           initialized before use in a function     53           initialized before use in a function.
 54                                                    54 
 55         config INIT_STACK_NONE                     55         config INIT_STACK_NONE
 56                 bool "no automatic stack varia     56                 bool "no automatic stack variable initialization (weakest)"
 57                 help                               57                 help
 58                   Disable automatic stack vari     58                   Disable automatic stack variable initialization.
 59                   This leaves the kernel vulne     59                   This leaves the kernel vulnerable to the standard
 60                   classes of uninitialized sta     60                   classes of uninitialized stack variable exploits
 61                   and information exposures.       61                   and information exposures.
 62                                                    62 
 63         config GCC_PLUGIN_STRUCTLEAK_USER          63         config GCC_PLUGIN_STRUCTLEAK_USER
 64                 bool "zero-init structs marked     64                 bool "zero-init structs marked for userspace (weak)"
 65                 # Plugin can be removed once t     65                 # Plugin can be removed once the kernel only supports GCC 12+
 66                 depends on GCC_PLUGINS && !CC_     66                 depends on GCC_PLUGINS && !CC_HAS_AUTO_VAR_INIT_ZERO
 67                 select GCC_PLUGIN_STRUCTLEAK       67                 select GCC_PLUGIN_STRUCTLEAK
 68                 help                               68                 help
 69                   Zero-initialize any structur     69                   Zero-initialize any structures on the stack containing
 70                   a __user attribute. This can     70                   a __user attribute. This can prevent some classes of
 71                   uninitialized stack variable     71                   uninitialized stack variable exploits and information
 72                   exposures, like CVE-2013-214     72                   exposures, like CVE-2013-2141:
 73                   https://git.kernel.org/linus     73                   https://git.kernel.org/linus/b9e146d8eb3b9eca
 74                                                    74 
 75         config GCC_PLUGIN_STRUCTLEAK_BYREF         75         config GCC_PLUGIN_STRUCTLEAK_BYREF
 76                 bool "zero-init structs passed     76                 bool "zero-init structs passed by reference (strong)"
 77                 # Plugin can be removed once t     77                 # Plugin can be removed once the kernel only supports GCC 12+
 78                 depends on GCC_PLUGINS && !CC_     78                 depends on GCC_PLUGINS && !CC_HAS_AUTO_VAR_INIT_ZERO
 79                 depends on !(KASAN && KASAN_ST     79                 depends on !(KASAN && KASAN_STACK)
 80                 select GCC_PLUGIN_STRUCTLEAK       80                 select GCC_PLUGIN_STRUCTLEAK
 81                 help                               81                 help
 82                   Zero-initialize any structur     82                   Zero-initialize any structures on the stack that may
 83                   be passed by reference and h     83                   be passed by reference and had not already been
 84                   explicitly initialized. This     84                   explicitly initialized. This can prevent most classes
 85                   of uninitialized stack varia     85                   of uninitialized stack variable exploits and information
 86                   exposures, like CVE-2017-100     86                   exposures, like CVE-2017-1000410:
 87                   https://git.kernel.org/linus     87                   https://git.kernel.org/linus/06e7e776ca4d3654
 88                                                    88 
 89                   As a side-effect, this keeps     89                   As a side-effect, this keeps a lot of variables on the
 90                   stack that can otherwise be      90                   stack that can otherwise be optimized out, so combining
 91                   this with CONFIG_KASAN_STACK     91                   this with CONFIG_KASAN_STACK can lead to a stack overflow
 92                   and is disallowed.               92                   and is disallowed.
 93                                                    93 
 94         config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL     94         config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL
 95                 bool "zero-init everything pas     95                 bool "zero-init everything passed by reference (very strong)"
 96                 # Plugin can be removed once t     96                 # Plugin can be removed once the kernel only supports GCC 12+
 97                 depends on GCC_PLUGINS && !CC_     97                 depends on GCC_PLUGINS && !CC_HAS_AUTO_VAR_INIT_ZERO
 98                 depends on !(KASAN && KASAN_ST     98                 depends on !(KASAN && KASAN_STACK)
 99                 select GCC_PLUGIN_STRUCTLEAK       99                 select GCC_PLUGIN_STRUCTLEAK
100                 help                              100                 help
101                   Zero-initialize any stack va    101                   Zero-initialize any stack variables that may be passed
102                   by reference and had not alr    102                   by reference and had not already been explicitly
103                   initialized. This is intende    103                   initialized. This is intended to eliminate all classes
104                   of uninitialized stack varia    104                   of uninitialized stack variable exploits and information
105                   exposures.                      105                   exposures.
106                                                   106 
107                   As a side-effect, this keeps    107                   As a side-effect, this keeps a lot of variables on the
108                   stack that can otherwise be     108                   stack that can otherwise be optimized out, so combining
109                   this with CONFIG_KASAN_STACK    109                   this with CONFIG_KASAN_STACK can lead to a stack overflow
110                   and is disallowed.              110                   and is disallowed.
111                                                   111 
112         config INIT_STACK_ALL_PATTERN             112         config INIT_STACK_ALL_PATTERN
113                 bool "pattern-init everything     113                 bool "pattern-init everything (strongest)"
114                 depends on CC_HAS_AUTO_VAR_INI    114                 depends on CC_HAS_AUTO_VAR_INIT_PATTERN
115                 depends on !KMSAN              << 
116                 help                              115                 help
117                   Initializes everything on th    116                   Initializes everything on the stack (including padding)
118                   with a specific debug value.    117                   with a specific debug value. This is intended to eliminate
119                   all classes of uninitialized    118                   all classes of uninitialized stack variable exploits and
120                   information exposures, even     119                   information exposures, even variables that were warned about
121                   having been left uninitializ    120                   having been left uninitialized.
122                                                   121 
123                   Pattern initialization is kn    122                   Pattern initialization is known to provoke many existing bugs
124                   related to uninitialized loc    123                   related to uninitialized locals, e.g. pointers receive
125                   non-NULL values, buffer size    124                   non-NULL values, buffer sizes and indices are very big. The
126                   pattern is situation-specifi    125                   pattern is situation-specific; Clang on 64-bit uses 0xAA
127                   repeating for all types and     126                   repeating for all types and padding except float and double
128                   which use 0xFF repeating (-N    127                   which use 0xFF repeating (-NaN). Clang on 32-bit uses 0xFF
129                   repeating for all types and     128                   repeating for all types and padding.
130                                                   129 
131         config INIT_STACK_ALL_ZERO                130         config INIT_STACK_ALL_ZERO
132                 bool "zero-init everything (st    131                 bool "zero-init everything (strongest and safest)"
133                 depends on CC_HAS_AUTO_VAR_INI    132                 depends on CC_HAS_AUTO_VAR_INIT_ZERO
134                 depends on !KMSAN              << 
135                 help                              133                 help
136                   Initializes everything on th    134                   Initializes everything on the stack (including padding)
137                   with a zero value. This is i    135                   with a zero value. This is intended to eliminate all
138                   classes of uninitialized sta    136                   classes of uninitialized stack variable exploits and
139                   information exposures, even     137                   information exposures, even variables that were warned
140                   about having been left unini    138                   about having been left uninitialized.
141                                                   139 
142                   Zero initialization provides    140                   Zero initialization provides safe defaults for strings
143                   (immediately NUL-terminated)    141                   (immediately NUL-terminated), pointers (NULL), indices
144                   (index 0), and sizes (0 leng    142                   (index 0), and sizes (0 length), so it is therefore more
145                   suitable as a production sec    143                   suitable as a production security mitigation than pattern
146                   initialization.                 144                   initialization.
147                                                   145 
148 endchoice                                         146 endchoice
149                                                   147 
150 config GCC_PLUGIN_STRUCTLEAK_VERBOSE              148 config GCC_PLUGIN_STRUCTLEAK_VERBOSE
151         bool "Report forcefully initialized va    149         bool "Report forcefully initialized variables"
152         depends on GCC_PLUGIN_STRUCTLEAK          150         depends on GCC_PLUGIN_STRUCTLEAK
153         depends on !COMPILE_TEST        # too     151         depends on !COMPILE_TEST        # too noisy
154         help                                      152         help
155           This option will cause a warning to     153           This option will cause a warning to be printed each time the
156           structleak plugin finds a variable i    154           structleak plugin finds a variable it thinks needs to be
157           initialized. Since not all existing     155           initialized. Since not all existing initializers are detected
158           by the plugin, this can produce fals    156           by the plugin, this can produce false positive warnings.
159                                                   157 
160 config GCC_PLUGIN_STACKLEAK                       158 config GCC_PLUGIN_STACKLEAK
161         bool "Poison kernel stack before retur    159         bool "Poison kernel stack before returning from syscalls"
162         depends on GCC_PLUGINS                    160         depends on GCC_PLUGINS
163         depends on HAVE_ARCH_STACKLEAK            161         depends on HAVE_ARCH_STACKLEAK
164         help                                      162         help
165           This option makes the kernel erase t    163           This option makes the kernel erase the kernel stack before
166           returning from system calls. This ha    164           returning from system calls. This has the effect of leaving
167           the stack initialized to the poison     165           the stack initialized to the poison value, which both reduces
168           the lifetime of any sensitive stack     166           the lifetime of any sensitive stack contents and reduces
169           potential for uninitialized stack va    167           potential for uninitialized stack variable exploits or information
170           exposures (it does not cover functio    168           exposures (it does not cover functions reaching the same stack
171           depth as prior functions during the     169           depth as prior functions during the same syscall). This blocks
172           most uninitialized stack variable at    170           most uninitialized stack variable attacks, with the performance
173           impact being driven by the depth of     171           impact being driven by the depth of the stack usage, rather than
174           the function calling complexity.        172           the function calling complexity.
175                                                   173 
176           The performance impact on a single C    174           The performance impact on a single CPU system kernel compilation
177           sees a 1% slowdown, other systems an    175           sees a 1% slowdown, other systems and workloads may vary and you
178           are advised to test this feature on     176           are advised to test this feature on your expected workload before
179           deploying it.                           177           deploying it.
180                                                   178 
181           This plugin was ported from grsecuri    179           This plugin was ported from grsecurity/PaX. More information at:
182            * https://grsecurity.net/              180            * https://grsecurity.net/
183            * https://pax.grsecurity.net/          181            * https://pax.grsecurity.net/
184                                                   182 
185 config GCC_PLUGIN_STACKLEAK_VERBOSE               183 config GCC_PLUGIN_STACKLEAK_VERBOSE
186         bool "Report stack depth analysis inst    184         bool "Report stack depth analysis instrumentation" if EXPERT
187         depends on GCC_PLUGIN_STACKLEAK           185         depends on GCC_PLUGIN_STACKLEAK
188         depends on !COMPILE_TEST        # too     186         depends on !COMPILE_TEST        # too noisy
189         help                                      187         help
190           This option will cause a warning to     188           This option will cause a warning to be printed each time the
191           stackleak plugin finds a function it    189           stackleak plugin finds a function it thinks needs to be
192           instrumented. This is useful for com    190           instrumented. This is useful for comparing coverage between
193           builds.                                 191           builds.
194                                                   192 
195 config STACKLEAK_TRACK_MIN_SIZE                   193 config STACKLEAK_TRACK_MIN_SIZE
196         int "Minimum stack frame size of funct    194         int "Minimum stack frame size of functions tracked by STACKLEAK"
197         default 100                               195         default 100
198         range 0 4096                              196         range 0 4096
199         depends on GCC_PLUGIN_STACKLEAK           197         depends on GCC_PLUGIN_STACKLEAK
200         help                                      198         help
201           The STACKLEAK gcc plugin instruments    199           The STACKLEAK gcc plugin instruments the kernel code for tracking
202           the lowest border of the kernel stac    200           the lowest border of the kernel stack (and for some other purposes).
203           It inserts the stackleak_track_stack    201           It inserts the stackleak_track_stack() call for the functions with
204           a stack frame size greater than or e    202           a stack frame size greater than or equal to this parameter.
205           If unsure, leave the default value 1    203           If unsure, leave the default value 100.
206                                                   204 
207 config STACKLEAK_METRICS                          205 config STACKLEAK_METRICS
208         bool "Show STACKLEAK metrics in the /p    206         bool "Show STACKLEAK metrics in the /proc file system"
209         depends on GCC_PLUGIN_STACKLEAK           207         depends on GCC_PLUGIN_STACKLEAK
210         depends on PROC_FS                        208         depends on PROC_FS
211         help                                      209         help
212           If this is set, STACKLEAK metrics fo    210           If this is set, STACKLEAK metrics for every task are available in
213           the /proc file system. In particular    211           the /proc file system. In particular, /proc/<pid>/stack_depth
214           shows the maximum kernel stack consu    212           shows the maximum kernel stack consumption for the current and
215           previous syscalls. Although this inf    213           previous syscalls. Although this information is not precise, it
216           can be useful for estimating the STA    214           can be useful for estimating the STACKLEAK performance impact for
217           your workloads.                         215           your workloads.
218                                                   216 
219 config STACKLEAK_RUNTIME_DISABLE                  217 config STACKLEAK_RUNTIME_DISABLE
220         bool "Allow runtime disabling of kerne    218         bool "Allow runtime disabling of kernel stack erasing"
221         depends on GCC_PLUGIN_STACKLEAK           219         depends on GCC_PLUGIN_STACKLEAK
222         help                                      220         help
223           This option provides 'stack_erasing'    221           This option provides 'stack_erasing' sysctl, which can be used in
224           runtime to control kernel stack eras    222           runtime to control kernel stack erasing for kernels built with
225           CONFIG_GCC_PLUGIN_STACKLEAK.            223           CONFIG_GCC_PLUGIN_STACKLEAK.
226                                                   224 
227 config INIT_ON_ALLOC_DEFAULT_ON                   225 config INIT_ON_ALLOC_DEFAULT_ON
228         bool "Enable heap memory zeroing on al    226         bool "Enable heap memory zeroing on allocation by default"
229         depends on !KMSAN                      << 
230         help                                      227         help
231           This has the effect of setting "init    228           This has the effect of setting "init_on_alloc=1" on the kernel
232           command line. This can be disabled w    229           command line. This can be disabled with "init_on_alloc=0".
233           When "init_on_alloc" is enabled, all    230           When "init_on_alloc" is enabled, all page allocator and slab
234           allocator memory will be zeroed when    231           allocator memory will be zeroed when allocated, eliminating
235           many kinds of "uninitialized heap me    232           many kinds of "uninitialized heap memory" flaws, especially
236           heap content exposures. The performa    233           heap content exposures. The performance impact varies by
237           workload, but most cases see <1% imp    234           workload, but most cases see <1% impact. Some synthetic
238           workloads have measured as high as 7    235           workloads have measured as high as 7%.
239                                                   236 
240 config INIT_ON_FREE_DEFAULT_ON                    237 config INIT_ON_FREE_DEFAULT_ON
241         bool "Enable heap memory zeroing on fr    238         bool "Enable heap memory zeroing on free by default"
242         depends on !KMSAN                      << 
243         help                                      239         help
244           This has the effect of setting "init    240           This has the effect of setting "init_on_free=1" on the kernel
245           command line. This can be disabled w    241           command line. This can be disabled with "init_on_free=0".
246           Similar to "init_on_alloc", when "in    242           Similar to "init_on_alloc", when "init_on_free" is enabled,
247           all page allocator and slab allocato    243           all page allocator and slab allocator memory will be zeroed
248           when freed, eliminating many kinds o    244           when freed, eliminating many kinds of "uninitialized heap memory"
249           flaws, especially heap content expos    245           flaws, especially heap content exposures. The primary difference
250           with "init_on_free" is that data lif    246           with "init_on_free" is that data lifetime in memory is reduced,
251           as anything freed is wiped immediate    247           as anything freed is wiped immediately, making live forensics or
252           cold boot memory attacks unable to r    248           cold boot memory attacks unable to recover freed memory contents.
253           The performance impact varies by wor    249           The performance impact varies by workload, but is more expensive
254           than "init_on_alloc" due to the nega    250           than "init_on_alloc" due to the negative cache effects of
255           touching "cold" memory areas. Most c    251           touching "cold" memory areas. Most cases see 3-5% impact. Some
256           synthetic workloads have measured as    252           synthetic workloads have measured as high as 8%.
257                                                   253 
258 config CC_HAS_ZERO_CALL_USED_REGS                 254 config CC_HAS_ZERO_CALL_USED_REGS
259         def_bool $(cc-option,-fzero-call-used-    255         def_bool $(cc-option,-fzero-call-used-regs=used-gpr)
260         # https://github.com/ClangBuiltLinux/l << 
261         # https://github.com/llvm/llvm-project << 
262         depends on !CC_IS_CLANG || CLANG_VERSI << 
263                                                   256 
264 config ZERO_CALL_USED_REGS                        257 config ZERO_CALL_USED_REGS
265         bool "Enable register zeroing on funct    258         bool "Enable register zeroing on function exit"
266         depends on CC_HAS_ZERO_CALL_USED_REGS     259         depends on CC_HAS_ZERO_CALL_USED_REGS
267         help                                      260         help
268           At the end of functions, always zero    261           At the end of functions, always zero any caller-used register
269           contents. This helps ensure that tem    262           contents. This helps ensure that temporary values are not
270           leaked beyond the function boundary.    263           leaked beyond the function boundary. This means that register
271           contents are less likely to be avail    264           contents are less likely to be available for side channels
272           and information exposures. Additiona    265           and information exposures. Additionally, this helps reduce the
273           number of useful ROP gadgets by abou    266           number of useful ROP gadgets by about 20% (and removes compiler
274           generated "write-what-where" gadgets    267           generated "write-what-where" gadgets) in the resulting kernel
275           image. This has a less than 1% perfo    268           image. This has a less than 1% performance impact on most
276           workloads. Image size growth depends    269           workloads. Image size growth depends on architecture, and should
277           be evaluated for suitability. For ex    270           be evaluated for suitability. For example, x86_64 grows by less
278           than 1%, and arm64 grows by about 5%    271           than 1%, and arm64 grows by about 5%.
279                                                   272 
280 endmenu                                           273 endmenu
281                                                   274 
282 menu "Hardening of kernel data structures"     << 
283                                                << 
284 config LIST_HARDENED                           << 
285         bool "Check integrity of linked list m << 
286         help                                   << 
287           Minimal integrity checking in the li << 
288           to catch memory corruptions that are << 
289           immediate access fault.              << 
290                                                << 
291           If unsure, say N.                    << 
292                                                << 
293 config BUG_ON_DATA_CORRUPTION                  << 
294         bool "Trigger a BUG when data corrupti << 
295         select LIST_HARDENED                   << 
296         help                                   << 
297           Select this option if the kernel sho << 
298           data corruption in kernel memory str << 
299           for validity.                        << 
300                                                << 
301           If unsure, say N.                    << 
302                                                << 
303 endmenu                                        << 
304                                                << 
305 config CC_HAS_RANDSTRUCT                          275 config CC_HAS_RANDSTRUCT
306         def_bool $(cc-option,-frandomize-layou    276         def_bool $(cc-option,-frandomize-layout-seed-file=/dev/null)
307         # Randstruct was first added in Clang  << 
308         # Clang 16 due to https://github.com/l << 
309         depends on !CC_IS_CLANG || CLANG_VERSI << 
310                                                   277 
311 choice                                            278 choice
312         prompt "Randomize layout of sensitive     279         prompt "Randomize layout of sensitive kernel structures"
313         default RANDSTRUCT_FULL if COMPILE_TES    280         default RANDSTRUCT_FULL if COMPILE_TEST && (GCC_PLUGINS || CC_HAS_RANDSTRUCT)
314         default RANDSTRUCT_NONE                   281         default RANDSTRUCT_NONE
315         help                                      282         help
316           If you enable this, the layouts of s    283           If you enable this, the layouts of structures that are entirely
317           function pointers (and have not been    284           function pointers (and have not been manually annotated with
318           __no_randomize_layout), or structure    285           __no_randomize_layout), or structures that have been explicitly
319           marked with __randomize_layout, will    286           marked with __randomize_layout, will be randomized at compile-time.
320           This can introduce the requirement o    287           This can introduce the requirement of an additional information
321           exposure vulnerability for exploits     288           exposure vulnerability for exploits targeting these structure
322           types.                                  289           types.
323                                                   290 
324           Enabling this feature will introduce    291           Enabling this feature will introduce some performance impact,
325           slightly increase memory usage, and     292           slightly increase memory usage, and prevent the use of forensic
326           tools like Volatility against the sy    293           tools like Volatility against the system (unless the kernel
327           source tree isn't cleaned after kern    294           source tree isn't cleaned after kernel installation).
328                                                   295 
329           The seed used for compilation is in     296           The seed used for compilation is in scripts/basic/randomize.seed.
330           It remains after a "make clean" to a    297           It remains after a "make clean" to allow for external modules to
331           be compiled with the existing seed a    298           be compiled with the existing seed and will be removed by a
332           "make mrproper" or "make distclean".    299           "make mrproper" or "make distclean". This file should not be made
333           public, or the structure layout can     300           public, or the structure layout can be determined.
334                                                   301 
335         config RANDSTRUCT_NONE                    302         config RANDSTRUCT_NONE
336                 bool "Disable structure layout    303                 bool "Disable structure layout randomization"
337                 help                              304                 help
338                   Build normally: no structure    305                   Build normally: no structure layout randomization.
339                                                   306 
340         config RANDSTRUCT_FULL                    307         config RANDSTRUCT_FULL
341                 bool "Fully randomize structur    308                 bool "Fully randomize structure layout"
342                 depends on CC_HAS_RANDSTRUCT |    309                 depends on CC_HAS_RANDSTRUCT || GCC_PLUGINS
343                 select MODVERSIONS if MODULES  !! 310                 select MODVERSIONS if MODULES
344                 help                              311                 help
345                   Fully randomize the member l    312                   Fully randomize the member layout of sensitive
346                   structures as much as possib    313                   structures as much as possible, which may have both a
347                   memory size and performance     314                   memory size and performance impact.
348                                                   315 
349                   One difference between the C    316                   One difference between the Clang and GCC plugin
350                   implementations is the handl    317                   implementations is the handling of bitfields. The GCC
351                   plugin treats them as fully     318                   plugin treats them as fully separate variables,
352                   introducing sometimes signif    319                   introducing sometimes significant padding. Clang tries
353                   to keep adjacent bitfields t    320                   to keep adjacent bitfields together, but with their bit
354                   ordering randomized.            321                   ordering randomized.
355                                                   322 
356         config RANDSTRUCT_PERFORMANCE             323         config RANDSTRUCT_PERFORMANCE
357                 bool "Limit randomization of s    324                 bool "Limit randomization of structure layout to cache-lines"
358                 depends on GCC_PLUGINS            325                 depends on GCC_PLUGINS
359                 select MODVERSIONS if MODULES  !! 326                 select MODVERSIONS if MODULES
360                 help                              327                 help
361                   Randomization of sensitive k    328                   Randomization of sensitive kernel structures will make a
362                   best effort at restricting r    329                   best effort at restricting randomization to cacheline-sized
363                   groups of members. It will f    330                   groups of members. It will further not randomize bitfields
364                   in structures. This reduces     331                   in structures. This reduces the performance hit of RANDSTRUCT
365                   at the cost of weakened rand    332                   at the cost of weakened randomization.
366 endchoice                                         333 endchoice
367                                                   334 
368 config RANDSTRUCT                                 335 config RANDSTRUCT
369         def_bool !RANDSTRUCT_NONE                 336         def_bool !RANDSTRUCT_NONE
370                                                   337 
371 config GCC_PLUGIN_RANDSTRUCT                      338 config GCC_PLUGIN_RANDSTRUCT
372         def_bool GCC_PLUGINS && RANDSTRUCT        339         def_bool GCC_PLUGINS && RANDSTRUCT
373         help                                      340         help
374           Use GCC plugin to randomize structur    341           Use GCC plugin to randomize structure layout.
375                                                   342 
376           This plugin was ported from grsecuri    343           This plugin was ported from grsecurity/PaX. More
377           information at:                         344           information at:
378            * https://grsecurity.net/              345            * https://grsecurity.net/
379            * https://pax.grsecurity.net/          346            * https://pax.grsecurity.net/
380                                                   347 
381 endmenu                                           348 endmenu
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php