]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - lib/Kconfig.ubsan
media: tw68: Replace http links with https ones
[mirror_ubuntu-hirsute-kernel.git] / lib / Kconfig.ubsan
CommitLineData
ec8f24b7 1# SPDX-License-Identifier: GPL-2.0-only
c6d30853
AR
2config ARCH_HAS_UBSAN_SANITIZE_ALL
3 bool
4
277a1085 5menuconfig UBSAN
c6d30853
AR
6 bool "Undefined behaviour sanity checker"
7 help
0887a7eb 8 This option enables the Undefined Behaviour sanity checker.
c6d30853 9 Compile-time instrumentation is used to detect various undefined
0887a7eb
KC
10 behaviours at runtime. For more details, see:
11 Documentation/dev-tools/ubsan.rst
12
277a1085
KC
13if UBSAN
14
0887a7eb
KC
15config UBSAN_TRAP
16 bool "On Sanitizer warnings, abort the running kernel code"
0887a7eb
KC
17 depends on $(cc-option, -fsanitize-undefined-trap-on-error)
18 help
19 Building kernels with Sanitizer features enabled tends to grow
20 the kernel size by around 5%, due to adding all the debugging
21 text on failure paths. To avoid this, Sanitizer instrumentation
22 can just issue a trap. This reduces the kernel size overhead but
23 turns all warnings (including potentially harmless conditions)
24 into full exceptions that abort the running kernel code
25 (regardless of context, locks held, etc), which may destabilize
26 the system. For some system builders this is an acceptable
27 trade-off.
c6d30853 28
ea91a1d4
AB
29config UBSAN_KCOV_BROKEN
30 def_bool KCOV && CC_HAS_SANCOV_TRACE_PC
31 depends on CC_IS_CLANG
32 depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=bounds -fsanitize-coverage=trace-pc)
33 help
34 Some versions of clang support either UBSAN or KCOV but not the
35 combination of the two.
36 See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status
37 in newer releases.
38
277a1085
KC
39config UBSAN_BOUNDS
40 bool "Perform array index bounds checking"
41 default UBSAN
ea91a1d4 42 depends on !UBSAN_KCOV_BROKEN
277a1085
KC
43 help
44 This option enables detection of directly indexed out of bounds
45 array accesses, where the array size is known at compile time.
46 Note that this does not protect array overflows via bad calls
47 to the {str,mem}*cpy() family of functions (that is addressed
48 by CONFIG_FORTIFY_SOURCE).
49
50config UBSAN_MISC
51 bool "Enable all other Undefined Behavior sanity checks"
52 default UBSAN
53 help
54 This option enables all sanity checks that don't have their
55 own Kconfig options. Disable this if you only want to have
56 individually selected checks.
57
c6d30853
AR
58config UBSAN_SANITIZE_ALL
59 bool "Enable instrumentation for the entire kernel"
c6d30853 60 depends on ARCH_HAS_UBSAN_SANITIZE_ALL
dde5cf39
AR
61
62 # We build with -Wno-maybe-uninitilzed, but we still want to
63 # use -Wmaybe-uninitilized in allmodconfig builds.
64 # So dependsy bellow used to disable this option in allmodconfig
65 depends on !COMPILE_TEST
c6d30853
AR
66 default y
67 help
68 This option activates instrumentation for the entire kernel.
69 If you don't enable this option, you have to explicitly specify
70 UBSAN_SANITIZE := y for the files/directories you want to check for UB.
7707535a
YS
71 Enabling this option will get kernel image size increased
72 significantly.
c6d30853 73
8d58f222
KC
74config UBSAN_ALIGNMENT
75 bool "Enable checks for pointers alignment"
76 default !HAVE_EFFICIENT_UNALIGNED_ACCESS
9380ce24 77 depends on !UBSAN_TRAP
c6d30853 78 help
8d58f222
KC
79 This option enables the check of unaligned memory accesses.
80 Enabling this option on architectures that support unaligned
c6d30853 81 accesses may produce a lot of false positives.
725c4d22 82
854686f4
JP
83config TEST_UBSAN
84 tristate "Module for testing for undefined behavior detection"
277a1085 85 depends on m
854686f4
JP
86 help
87 This is a test module for UBSAN.
88 It triggers various undefined behavior, and detect it.
277a1085
KC
89
90endif # if UBSAN