Skip to content

Commit 918327e

Browse files
committed
ubsan: Remove CONFIG_UBSAN_SANITIZE_ALL
For simplicity in splitting out UBSan options into separate rules, remove CONFIG_UBSAN_SANITIZE_ALL, effectively defaulting to "y", which is how it is generally used anyway. (There are no ":= y" cases beyond where a specific file is enabled when a top-level ":= n" is in effect.) Cc: Andrey Konovalov <[email protected]> Cc: Marco Elver <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 30edbdf commit 918327e

File tree

11 files changed

+18
-41
lines changed

11 files changed

+18
-41
lines changed

Documentation/dev-tools/ubsan.rst

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,22 @@ Report example
4949
Usage
5050
-----
5151

52-
To enable UBSAN configure kernel with::
52+
To enable UBSAN, configure the kernel with::
5353

54-
CONFIG_UBSAN=y
54+
CONFIG_UBSAN=y
5555

56-
and to check the entire kernel::
57-
58-
CONFIG_UBSAN_SANITIZE_ALL=y
59-
60-
To enable instrumentation for specific files or directories, add a line
61-
similar to the following to the respective kernel Makefile:
62-
63-
- For a single file (e.g. main.o)::
64-
65-
UBSAN_SANITIZE_main.o := y
66-
67-
- For all files in one directory::
68-
69-
UBSAN_SANITIZE := y
70-
71-
To exclude files from being instrumented even if
72-
``CONFIG_UBSAN_SANITIZE_ALL=y``, use::
56+
To exclude files from being instrumented use::
7357

7458
UBSAN_SANITIZE_main.o := n
7559

76-
and::
60+
and to exclude all targets in one directory use::
7761

7862
UBSAN_SANITIZE := n
7963

64+
When disabled for all targets, specific files can be enabled using::
65+
66+
UBSAN_SANITIZE_main.o := y
67+
8068
Detection of unaligned accesses controlled through the separate option -
8169
CONFIG_UBSAN_ALIGNMENT. It's off by default on architectures that support
8270
unaligned accesses (CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y). One could

arch/arm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ config ARM
2929
select ARCH_HAVE_NMI_SAFE_CMPXCHG if CPU_V7 || CPU_V7M || CPU_V6K
3030
select ARCH_HAS_GCOV_PROFILE_ALL
3131
select ARCH_KEEP_MEMBLOCK
32-
select ARCH_HAS_UBSAN_SANITIZE_ALL
32+
select ARCH_HAS_UBSAN
3333
select ARCH_MIGHT_HAVE_PC_PARPORT
3434
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
3535
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT if CPU_V7

arch/arm64/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ config ARM64
107107
select ARCH_WANT_LD_ORPHAN_WARN
108108
select ARCH_WANTS_NO_INSTR
109109
select ARCH_WANTS_THP_SWAP if ARM64_4K_PAGES
110-
select ARCH_HAS_UBSAN_SANITIZE_ALL
110+
select ARCH_HAS_UBSAN
111111
select ARM_AMBA
112112
select ARM_ARCH_TIMER
113113
select ARM_GIC

arch/mips/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ config MIPS
1414
select ARCH_HAS_STRNCPY_FROM_USER
1515
select ARCH_HAS_STRNLEN_USER
1616
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
17-
select ARCH_HAS_UBSAN_SANITIZE_ALL
17+
select ARCH_HAS_UBSAN
1818
select ARCH_HAS_GCOV_PROFILE_ALL
1919
select ARCH_KEEP_MEMBLOCK
2020
select ARCH_USE_BUILTIN_BSWAP

arch/parisc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ config PARISC
1212
select ARCH_HAS_ELF_RANDOMIZE
1313
select ARCH_HAS_STRICT_KERNEL_RWX
1414
select ARCH_HAS_STRICT_MODULE_RWX
15-
select ARCH_HAS_UBSAN_SANITIZE_ALL
15+
select ARCH_HAS_UBSAN
1616
select ARCH_HAS_PTE_SPECIAL
1717
select ARCH_NO_SG_CHAIN
1818
select ARCH_SUPPORTS_HUGETLBFS if PA20

arch/powerpc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ config PPC
154154
select ARCH_HAS_SYSCALL_WRAPPER if !SPU_BASE && !COMPAT
155155
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
156156
select ARCH_HAS_UACCESS_FLUSHCACHE
157-
select ARCH_HAS_UBSAN_SANITIZE_ALL
157+
select ARCH_HAS_UBSAN
158158
select ARCH_HAVE_NMI_SAFE_CMPXCHG
159159
select ARCH_KEEP_MEMBLOCK
160160
select ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE if PPC_RADIX_MMU

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ config RISCV
3737
select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
3838
select ARCH_HAS_SYSCALL_WRAPPER
3939
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
40-
select ARCH_HAS_UBSAN_SANITIZE_ALL
40+
select ARCH_HAS_UBSAN
4141
select ARCH_HAS_VDSO_DATA
4242
select ARCH_KEEP_MEMBLOCK if ACPI
4343
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX

arch/s390/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ config S390
8282
select ARCH_HAS_STRICT_KERNEL_RWX
8383
select ARCH_HAS_STRICT_MODULE_RWX
8484
select ARCH_HAS_SYSCALL_WRAPPER
85-
select ARCH_HAS_UBSAN_SANITIZE_ALL
85+
select ARCH_HAS_UBSAN
8686
select ARCH_HAS_VDSO_DATA
8787
select ARCH_HAVE_NMI_SAFE_CMPXCHG
8888
select ARCH_INLINE_READ_LOCK

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ config X86
100100
select ARCH_HAS_STRICT_MODULE_RWX
101101
select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
102102
select ARCH_HAS_SYSCALL_WRAPPER
103-
select ARCH_HAS_UBSAN_SANITIZE_ALL
103+
select ARCH_HAS_UBSAN
104104
select ARCH_HAS_DEBUG_WX
105105
select ARCH_HAS_ZONE_DMA_SET if EXPERT
106106
select ARCH_HAVE_NMI_SAFE_CMPXCHG

lib/Kconfig.ubsan

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0-only
2-
config ARCH_HAS_UBSAN_SANITIZE_ALL
2+
config ARCH_HAS_UBSAN
33
bool
44

55
menuconfig UBSAN
@@ -142,17 +142,6 @@ config UBSAN_ALIGNMENT
142142
Enabling this option on architectures that support unaligned
143143
accesses may produce a lot of false positives.
144144

145-
config UBSAN_SANITIZE_ALL
146-
bool "Enable instrumentation for the entire kernel"
147-
depends on ARCH_HAS_UBSAN_SANITIZE_ALL
148-
default y
149-
help
150-
This option activates instrumentation for the entire kernel.
151-
If you don't enable this option, you have to explicitly specify
152-
UBSAN_SANITIZE := y for the files/directories you want to check for UB.
153-
Enabling this option will get kernel image size increased
154-
significantly.
155-
156145
config TEST_UBSAN
157146
tristate "Module for testing for undefined behavior detection"
158147
depends on m

scripts/Makefile.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ endif
175175

176176
ifeq ($(CONFIG_UBSAN),y)
177177
_c_flags += $(if $(patsubst n%,, \
178-
$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
178+
$(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)y), \
179179
$(CFLAGS_UBSAN))
180180
endif
181181

0 commit comments

Comments
 (0)