Makefile.kasan 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. # SPDX-License-Identifier: GPL-2.0
  2. ifdef CONFIG_KASAN
  3. ifdef CONFIG_KASAN_INLINE
  4. call_threshold := 10000
  5. else
  6. call_threshold := 0
  7. endif
  8. KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
  9. CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address
  10. CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \
  11. -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET) \
  12. --param asan-stack=1 --param asan-globals=1 \
  13. --param asan-instrumentation-with-call-threshold=$(call_threshold))
  14. ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
  15. ifneq ($(CONFIG_COMPILE_TEST),y)
  16. $(warning Cannot use CONFIG_KASAN: \
  17. -fsanitize=kernel-address is not supported by compiler)
  18. endif
  19. else
  20. ifeq ($(CFLAGS_KASAN),)
  21. ifneq ($(CONFIG_COMPILE_TEST),y)
  22. $(warning CONFIG_KASAN: compiler does not support all options.\
  23. Trying minimal configuration)
  24. endif
  25. CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
  26. endif
  27. endif
  28. CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope)
  29. endif