From 13a0682340b9d975535359ce4fb16d6814c7927d Mon Sep 17 00:00:00 2001 From: ligd Date: Wed, 27 Mar 2024 10:58:40 +0800 Subject: [PATCH] kasan: disable the built-in 'memset' function In function kasan_set_poison: { ... while (size--) { p[size] = value; } } This will optimize to 'memset' function when compile option > O2. But the memset must be instrument by kasan, so there is recursive Signed-off-by: ligd --- mm/kasan/CMakeLists.txt | 1 + mm/kasan/Make.defs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mm/kasan/CMakeLists.txt b/mm/kasan/CMakeLists.txt index 8252112e34..3f7e32d668 100644 --- a/mm/kasan/CMakeLists.txt +++ b/mm/kasan/CMakeLists.txt @@ -25,6 +25,7 @@ if(CONFIG_MM_KASAN) list(APPEND SRCS generic.c) set_source_files_properties(generic.c PROPERTIES COMPILE_FLAGS -fno-sanitize=kernel-address) + set_source_files_properties(generic.c PROPERTIES COMPILE_FLAGS -fno-builtin) set_source_files_properties(generic.c PROPERTIES COMPILE_FLAGS -fno-lto) endif() diff --git a/mm/kasan/Make.defs b/mm/kasan/Make.defs index a2a15b6a03..bc8e0c5696 100644 --- a/mm/kasan/Make.defs +++ b/mm/kasan/Make.defs @@ -43,6 +43,8 @@ ifeq ($(CONFIG_MM_KASAN),y) endif endif +CFLAGS += -fno-builtin + # Add the core heap directory to the build DEPPATH += --dep-path kasan