From 9de75d9cb52801c704de56188c49fa1c384218ff Mon Sep 17 00:00:00 2001 From: Elena Petrova Date: Mon, 7 Dec 2020 16:23:01 +0000 Subject: [PATCH] ANDROID: GKI: Enable bounds sanitizer Bounds sanitizer, a part of UndefinedBehaviorSanitizer (UBSan), inserts run time bounds checks when accessing structs and arrays of constant size known at compile time (e.g. in `foo[i]` for `char foo[8]`, `i` will be checked to be not greater than 8). The change have been tested to not have measurable performance impact. Bug: 175004266 Signed-off-by: Elena Petrova Change-Id: Ie02ac1b210eeea05ad9bb0bae4b60660648ae776 --- arch/arm64/configs/gki_defconfig | 8 ++++++++ arch/x86/configs/gki_defconfig | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/arm64/configs/gki_defconfig b/arch/arm64/configs/gki_defconfig index dab023c49a49..2d99de63681b 100644 --- a/arch/arm64/configs/gki_defconfig +++ b/arch/arm64/configs/gki_defconfig @@ -608,6 +608,14 @@ CONFIG_DEBUG_INFO_DWARF4=y CONFIG_HEADERS_INSTALL=y # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y +CONFIG_UBSAN=y +CONFIG_UBSAN_TRAP=y +CONFIG_UBSAN_LOCAL_BOUNDS=y +# CONFIG_UBSAN_SHIFT is not set +# CONFIG_UBSAN_SIGNED_OVERFLOW is not set +# CONFIG_UBSAN_OBJECT_SIZE is not set +# CONFIG_UBSAN_BOOL is not set +# CONFIG_UBSAN_ENUM is not set CONFIG_PAGE_OWNER=y CONFIG_DEBUG_STACK_USAGE=y CONFIG_DEBUG_MEMORY_INIT=y diff --git a/arch/x86/configs/gki_defconfig b/arch/x86/configs/gki_defconfig index 259d1331b21c..57b745c8e5da 100644 --- a/arch/x86/configs/gki_defconfig +++ b/arch/x86/configs/gki_defconfig @@ -550,6 +550,14 @@ CONFIG_DEBUG_INFO_DWARF4=y CONFIG_HEADERS_INSTALL=y # CONFIG_SECTION_MISMATCH_WARN_ONLY is not set CONFIG_MAGIC_SYSRQ=y +CONFIG_UBSAN=y +CONFIG_UBSAN_TRAP=y +CONFIG_UBSAN_LOCAL_BOUNDS=y +# CONFIG_UBSAN_SHIFT is not set +# CONFIG_UBSAN_SIGNED_OVERFLOW is not set +# CONFIG_UBSAN_OBJECT_SIZE is not set +# CONFIG_UBSAN_BOOL is not set +# CONFIG_UBSAN_ENUM is not set CONFIG_PAGE_OWNER=y CONFIG_DEBUG_STACK_USAGE=y CONFIG_DEBUG_MEMORY_INIT=y