From 7253e706590a24741af76cce91038d3ebe483152 Mon Sep 17 00:00:00 2001 From: leisiji <2265215145@qq.com> Date: Tue, 9 Jun 2026 07:55:44 +0800 Subject: [PATCH] mm/kasan: fix build fail when CONFIG_MM_KASAN_GLOBAL and CONFIG_BUILD_KERNEL on MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When CONFIG_MM_KASAN_GLOBAL is enabled, hook.c is also linked into libmm.a. However, g_global_region (defined in global.c) is only injected into the nuttx ELF by kasan_global.py — it does not process the app binary. This causes undefined symbol errors when linking an app against libmm.a. Guard the inclusion of global.c with __KERNEL__ so that only kernel builds pull in the global KASAN region, while app builds fall back to the no-op stub. Signed-off-by: leisiji <2265215145@qq.com> --- mm/kasan/hook.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/hook.c b/mm/kasan/hook.c index e1d1e129aa3..dcac69e5205 100644 --- a/mm/kasan/hook.c +++ b/mm/kasan/hook.c @@ -31,7 +31,7 @@ #include #include -#ifdef CONFIG_MM_KASAN_GLOBAL +#if defined(CONFIG_MM_KASAN_GLOBAL) && defined(__KERNEL__) # include "global.c" #else # define kasan_global_is_poisoned(addr, size) false