Thomas Gleixner | ec8f24b | 2019-05-19 13:07:45 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-only |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 2 | config ARCH_HAS_UBSAN_SANITIZE_ALL |
| 3 | bool |
| 4 | |
| 5 | config UBSAN |
| 6 | bool "Undefined behaviour sanity checker" |
| 7 | help |
| 8 | This option enables undefined behaviour sanity checker |
| 9 | Compile-time instrumentation is used to detect various undefined |
| 10 | behaviours in runtime. Various types of checks may be enabled |
Andreas Platschek | 0462554 | 2016-12-14 15:05:43 -0800 | [diff] [blame] | 11 | via boot parameter ubsan_handle |
| 12 | (see: Documentation/dev-tools/ubsan.rst). |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 13 | |
| 14 | config UBSAN_SANITIZE_ALL |
| 15 | bool "Enable instrumentation for the entire kernel" |
| 16 | depends on UBSAN |
| 17 | depends on ARCH_HAS_UBSAN_SANITIZE_ALL |
Andrey Ryabinin | dde5cf3 | 2016-03-22 14:27:45 -0700 | [diff] [blame] | 18 | |
| 19 | # We build with -Wno-maybe-uninitilzed, but we still want to |
| 20 | # use -Wmaybe-uninitilized in allmodconfig builds. |
| 21 | # So dependsy bellow used to disable this option in allmodconfig |
| 22 | depends on !COMPILE_TEST |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 23 | default y |
| 24 | help |
| 25 | This option activates instrumentation for the entire kernel. |
| 26 | If you don't enable this option, you have to explicitly specify |
| 27 | UBSAN_SANITIZE := y for the files/directories you want to check for UB. |
Yang Shi | 7707535 | 2016-02-11 16:12:55 -0800 | [diff] [blame] | 28 | Enabling this option will get kernel image size increased |
| 29 | significantly. |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 30 | |
Anders Roxell | 1a6a1db | 2019-03-07 16:30:16 -0800 | [diff] [blame] | 31 | config UBSAN_NO_ALIGNMENT |
| 32 | bool "Disable checking of pointers alignment" |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 33 | depends on UBSAN |
Anders Roxell | 1a6a1db | 2019-03-07 16:30:16 -0800 | [diff] [blame] | 34 | default y if HAVE_EFFICIENT_UNALIGNED_ACCESS |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 35 | help |
Anders Roxell | 1a6a1db | 2019-03-07 16:30:16 -0800 | [diff] [blame] | 36 | This option disables the check of unaligned memory accesses. |
| 37 | This option should be used when building allmodconfig. |
| 38 | Disabling this option on architectures that support unaligned |
Andrey Ryabinin | c6d3085 | 2016-01-20 15:00:55 -0800 | [diff] [blame] | 39 | accesses may produce a lot of false positives. |
Christian Borntraeger | 725c4d2 | 2016-09-12 14:37:19 +0200 | [diff] [blame] | 40 | |
Anders Roxell | 1a6a1db | 2019-03-07 16:30:16 -0800 | [diff] [blame] | 41 | config UBSAN_ALIGNMENT |
| 42 | def_bool !UBSAN_NO_ALIGNMENT |
| 43 | |
Jinbum Park | 854686f | 2018-04-10 16:32:58 -0700 | [diff] [blame] | 44 | config TEST_UBSAN |
| 45 | tristate "Module for testing for undefined behavior detection" |
| 46 | depends on m && UBSAN |
| 47 | help |
| 48 | This is a test module for UBSAN. |
| 49 | It triggers various undefined behavior, and detect it. |