Skip to content
Snippets Groups Projects
Commit c5fa7ec2 authored by Stijn Tintel's avatar Stijn Tintel
Browse files

kernel: add missing UBSAN config symbols


Enabling KERNEL_UBSAN exposes several missing symbols. Add new kernel
build options for UBSAN_BOUNDS and UBSAN_TRAP, disable CONFIG_TEST_UBSAN
in the generic kernel configs and enable CONFIG_UBSAN_MISC in generic
5.10 config. The latter symbol was removed in later kernels, as it was
causing some issues, so just disable it in 5.10 instead of adding a
build option for it.

Fixes build failures with KERNEL_UBSAN enabled.

Signed-off-by: default avatarStijn Tintel <stijn@linux-ipv6.be>
Acked-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
parent ec68c75c
No related branches found
No related tags found
No related merge requests found
...@@ -114,6 +114,16 @@ config KERNEL_UBSAN_ALIGNMENT ...@@ -114,6 +114,16 @@ config KERNEL_UBSAN_ALIGNMENT
Enabling this option on architectures that support unaligned Enabling this option on architectures that support unaligned
accesses may produce a lot of false positives. accesses may produce a lot of false positives.
config KERNEL_UBSAN_BOUNDS
bool "Perform array index bounds checking"
depends on KERNEL_UBSAN
help
This option enables detection of directly indexed out of bounds array
accesses, where the array size is known at compile time. Note that
this does not protect array overflows via bad calls to the
{str,mem}*cpy() family of functions (that is addressed by
FORTIFY_SOURCE).
config KERNEL_UBSAN_NULL config KERNEL_UBSAN_NULL
bool "Enable checking of null pointers" bool "Enable checking of null pointers"
depends on KERNEL_UBSAN depends on KERNEL_UBSAN
...@@ -121,6 +131,19 @@ config KERNEL_UBSAN_NULL ...@@ -121,6 +131,19 @@ config KERNEL_UBSAN_NULL
This option enables detection of memory accesses via a This option enables detection of memory accesses via a
null pointer. null pointer.
config KERNEL_UBSAN_TRAP
bool "On Sanitizer warnings, abort the running kernel code"
depends on KERNEL_UBSAN
help
Building kernels with Sanitizer features enabled tends to grow the
kernel size by around 5%, due to adding all the debugging text on
failure paths. To avoid this, Sanitizer instrumentation can just
issue a trap. This reduces the kernel size overhead but turns all
warnings (including potentially harmless conditions) into full
exceptions that abort the running kernel code (regardless of context,
locks held, etc), which may destabilize the system. For some system
builders this is an acceptable trade-off.
config KERNEL_KASAN config KERNEL_KASAN
bool "Compile the kernel with KASan: runtime memory debugger" bool "Compile the kernel with KASan: runtime memory debugger"
select KERNEL_SLUB_DEBUG select KERNEL_SLUB_DEBUG
......
...@@ -6083,6 +6083,7 @@ CONFIG_TCP_CONG_CUBIC=y ...@@ -6083,6 +6083,7 @@ CONFIG_TCP_CONG_CUBIC=y
# CONFIG_TEST_STRING_HELPERS is not set # CONFIG_TEST_STRING_HELPERS is not set
# CONFIG_TEST_STRSCPY is not set # CONFIG_TEST_STRSCPY is not set
# CONFIG_TEST_SYSCTL is not set # CONFIG_TEST_SYSCTL is not set
# CONFIG_TEST_UBSAN is not set
# CONFIG_TEST_UDELAY is not set # CONFIG_TEST_UDELAY is not set
# CONFIG_TEST_USER_COPY is not set # CONFIG_TEST_USER_COPY is not set
# CONFIG_TEST_UUID is not set # CONFIG_TEST_UUID is not set
...@@ -6349,6 +6350,7 @@ CONFIG_UBIFS_FS_ZLIB=y ...@@ -6349,6 +6350,7 @@ CONFIG_UBIFS_FS_ZLIB=y
CONFIG_UBIFS_FS_ZSTD=y CONFIG_UBIFS_FS_ZSTD=y
# CONFIG_UBSAN is not set # CONFIG_UBSAN is not set
CONFIG_UBSAN_ALIGNMENT=y CONFIG_UBSAN_ALIGNMENT=y
# CONFIG_UBSAN_MISC is not set
# CONFIG_UCB1400_CORE is not set # CONFIG_UCB1400_CORE is not set
# CONFIG_UCSI is not set # CONFIG_UCSI is not set
# CONFIG_UDF_FS is not set # CONFIG_UDF_FS is not set
......
...@@ -5631,6 +5631,7 @@ CONFIG_TCP_CONG_CUBIC=y ...@@ -5631,6 +5631,7 @@ CONFIG_TCP_CONG_CUBIC=y
# CONFIG_TEST_STRING_HELPERS is not set # CONFIG_TEST_STRING_HELPERS is not set
# CONFIG_TEST_STRSCPY is not set # CONFIG_TEST_STRSCPY is not set
# CONFIG_TEST_SYSCTL is not set # CONFIG_TEST_SYSCTL is not set
# CONFIG_TEST_UBSAN is not set
# CONFIG_TEST_UDELAY is not set # CONFIG_TEST_UDELAY is not set
# CONFIG_TEST_USER_COPY is not set # CONFIG_TEST_USER_COPY is not set
# CONFIG_TEST_UUID is not set # CONFIG_TEST_UUID is not set
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment