1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2bb273211SMasahiro Yamada 3cdf8a76fSKees Cook# Enable available and selected UBSAN features. 4cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_ALIGNMENT) += -fsanitize=alignment 52d47c695SKees Cookubsan-cflags-$(CONFIG_UBSAN_BOUNDS_STRICT) += -fsanitize=bounds-strict 6cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_ARRAY_BOUNDS) += -fsanitize=array-bounds 7cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_LOCAL_BOUNDS) += -fsanitize=local-bounds 8cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_SHIFT) += -fsanitize=shift 9cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_DIV_ZERO) += -fsanitize=integer-divide-by-zero 10cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_UNREACHABLE) += -fsanitize=unreachable 11cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_BOOL) += -fsanitize=bool 12cdf8a76fSKees Cookubsan-cflags-$(CONFIG_UBSAN_ENUM) += -fsanitize=enum 13167ebedaSKees Cookubsan-cflags-$(CONFIG_UBSAN_TRAP) += $(call cc-option,-fsanitize-trap=undefined,-fsanitize-undefined-trap-on-error) 14bb273211SMasahiro Yamada 15cdf8a76fSKees Cookexport CFLAGS_UBSAN := $(ubsan-cflags-y) 16557f8c58SKees Cook 17ed2b548fSKees Cookubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \ 18272a7670SKees Cook -fsanitize-undefined-ignore-overflow-pattern=all \ 19ed2b548fSKees Cook -fsanitize=signed-integer-overflow \ 20ed2b548fSKees Cook -fsanitize=unsigned-integer-overflow \ 21ed2b548fSKees Cook -fsanitize=implicit-signed-integer-truncation \ 22*47f4af43SKees Cook -fsanitize=implicit-unsigned-integer-truncation \ 23*47f4af43SKees Cook -fsanitize-ignorelist=$(srctree)/scripts/integer-wrap-ignore.scl 24ed2b548fSKees Cookexport CFLAGS_UBSAN_INTEGER_WRAP := $(ubsan-integer-wrap-cflags-y) 25