Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBSan: Allow custom the sanitizer in Kconfig #6986

Merged
merged 2 commits into from Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/arm/src/arm/Toolchain.defs
Expand Up @@ -84,7 +84,7 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv6-m/Toolchain.defs
Expand Up @@ -170,7 +170,7 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-a/Toolchain.defs
Expand Up @@ -125,7 +125,7 @@ ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-m/Toolchain.defs
Expand Up @@ -90,7 +90,7 @@ ifeq ($(CONFIG_ARMV7M_STACKCHECK),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-r/Toolchain.defs
Expand Up @@ -101,7 +101,7 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv8-m/Toolchain.defs
Expand Up @@ -90,7 +90,7 @@ ifeq ($(CONFIG_ARMV8M_STACKCHECK),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/Toolchain.defs
Expand Up @@ -63,7 +63,7 @@ ifeq ($(CONFIG_ARCH_COVERAGE_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/Toolchain.defs
Expand Up @@ -167,7 +167,7 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/lx6/Toolchain.defs
Expand Up @@ -48,7 +48,7 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/lx7/Toolchain.defs
Expand Up @@ -48,7 +48,7 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
4 changes: 2 additions & 2 deletions boards/sim/sim/sim/scripts/Make.defs
Expand Up @@ -78,9 +78,9 @@ else ifeq ($(CONFIG_MM_KASAN_ALL),y)
endif

ifeq ($(CONFIG_SIM_UBSAN),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
else ifeq ($(CONFIG_MM_UBSAN_ALL),y)
ARCHOPTIMIZATION += -fsanitize=undefined
ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
endif

ifeq ($(CONFIG_MM_UBSAN_TRAP_ON_ERROR),y)
Expand Down
11 changes: 10 additions & 1 deletion mm/Kconfig
Expand Up @@ -222,8 +222,17 @@ config MM_UBSAN_ALL
will get image size increased and performance decreased
significantly.

config MM_UBSAN_OPTION
string "UBSan options"
depends on MM_UBSAN
default "-fsanitize=undefined"
---help---
This option activates specified UBSan instrumentation. Please
refer to https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
for available options.

config MM_UBSAN_TRAP_ON_ERROR
bool "Enable UBsan trap on error to crash immediately"
bool "Enable UBSan trap on error to crash immediately"
depends on MM_UBSAN
default y
---help---
Expand Down