From eaf265b853d8d5db245ece31208381e96327d3fb Mon Sep 17 00:00:00 2001 From: Aleksei Vetrov Date: Thu, 24 Oct 2024 19:37:34 +0000 Subject: [PATCH] ANDROID: disable CONFIG_UBSAN_SIGNED_WRAP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After updating Clang to r536225 it started to sanitize signed integer overflow/underflow despite "-fwrapv" compiler flag. The "-fwrapv" flag is designed to treat signed integer as two’s complement unsigned integer with defined overflow/underflow. Sanitizing signed integer overflow in Linux kernel might be useful to spot bugs, however there are cases where overflow is intended, for example, `atomic_long_t` type and such cases can't be annotated to not trigger UBSAN. UBSAN was initially enabled for Android only for bounds sanitizer. Also we need to have UBSAN_TRAP to have kernel panic on out-of-bounds arrays access to harden the kernel. This change disables CONFIG_UBSAN_SIGNED_WRAP to make UBSAN function as bounds sanitizer only and don't trigger on signed integer wraps. Bug: 375156207 Bug: 354745907 Change-Id: I968edf7c8761505b6484cb4a46f6e948c39d7bab Signed-off-by: Aleksei Vetrov --- arch/arm64/configs/gki_defconfig | 1 + arch/x86/configs/gki_defconfig | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/arm64/configs/gki_defconfig b/arch/arm64/configs/gki_defconfig index aa6a63abfc58..a6c3b552cc53 100644 --- a/arch/arm64/configs/gki_defconfig +++ b/arch/arm64/configs/gki_defconfig @@ -723,6 +723,7 @@ CONFIG_HEADERS_INSTALL=y # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_UBSAN=y +# CONFIG_UBSAN_SIGNED_WRAP is not set # CONFIG_UBSAN_BOOL is not set # CONFIG_UBSAN_ENUM is not set CONFIG_PAGE_OWNER=y diff --git a/arch/x86/configs/gki_defconfig b/arch/x86/configs/gki_defconfig index 0a6db3bb4b4d..1d75f936b308 100644 --- a/arch/x86/configs/gki_defconfig +++ b/arch/x86/configs/gki_defconfig @@ -666,6 +666,7 @@ CONFIG_HEADERS_INSTALL=y # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y CONFIG_UBSAN=y +# CONFIG_UBSAN_SIGNED_WRAP is not set # CONFIG_UBSAN_BOOL is not set # CONFIG_UBSAN_ENUM is not set CONFIG_PAGE_OWNER=y