On Tue, Jul 22, 2025 at 4:00 AM Andrey Ryabinin <ryabinin....@gmail.com> wrote: > > > > On 7/17/25 4:27 PM, Sabyrzhan Tasbolatov wrote: > > UserMode Linux needs deferred KASAN initialization as it has a custom > > kasan_arch_is_ready() implementation that tracks shadow memory readiness > > via the kasan_um_is_ready flag. > > > > Select ARCH_DEFER_KASAN to enable the unified static key mechanism > > for runtime KASAN control. Call kasan_init_generic() which handles > > Generic KASAN initialization and enables the static key. > > > > Delete the key kasan_um_is_ready in favor of the unified kasan_enabled() > > interface. > > > > Note that kasan_init_generic has __init macro, which is called by > > kasan_init() which is not marked with __init in arch/um code. > > > > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217049 > > Signed-off-by: Sabyrzhan Tasbolatov <snovit...@gmail.com> > > --- > > Changes in v3: > > - Added CONFIG_ARCH_DEFER_KASAN selection for proper runtime control > > --- > > arch/um/Kconfig | 1 + > > arch/um/include/asm/kasan.h | 5 ----- > > arch/um/kernel/mem.c | 4 ++-- > > 3 files changed, 3 insertions(+), 7 deletions(-) > > > > diff --git a/arch/um/Kconfig b/arch/um/Kconfig > > index f08e8a7fac9..fd6d78bba52 100644 > > --- a/arch/um/Kconfig > > +++ b/arch/um/Kconfig > > @@ -8,6 +8,7 @@ config UML > > select ARCH_WANTS_DYNAMIC_TASK_STRUCT > > select ARCH_HAS_CPU_FINALIZE_INIT > > select ARCH_HAS_FORTIFY_SOURCE > > + select ARCH_DEFER_KASAN > > select ARCH_HAS_GCOV_PROFILE_ALL > > select ARCH_HAS_KCOV > > select ARCH_HAS_STRNCPY_FROM_USER > > diff --git a/arch/um/include/asm/kasan.h b/arch/um/include/asm/kasan.h > > index f97bb1f7b85..81bcdc0f962 100644 > > --- a/arch/um/include/asm/kasan.h > > +++ b/arch/um/include/asm/kasan.h > > @@ -24,11 +24,6 @@ > > > > #ifdef CONFIG_KASAN > > void kasan_init(void); > > -extern int kasan_um_is_ready; > > - > > -#ifdef CONFIG_STATIC_LINK > > -#define kasan_arch_is_ready() (kasan_um_is_ready) > > -#endif > > #else > > static inline void kasan_init(void) { } > > #endif /* CONFIG_KASAN */ > > diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c > > index 76bec7de81b..058cb70e330 100644 > > --- a/arch/um/kernel/mem.c > > +++ b/arch/um/kernel/mem.c > > @@ -21,9 +21,9 @@ > > #include <os.h> > > #include <um_malloc.h> > > #include <linux/sched/task.h> > > +#include <linux/kasan.h> > > > > #ifdef CONFIG_KASAN > > -int kasan_um_is_ready; > > void kasan_init(void) > > { > > /* > > @@ -32,7 +32,7 @@ void kasan_init(void) > > */ > > kasan_map_memory((void *)KASAN_SHADOW_START, KASAN_SHADOW_SIZE); > > init_task.kasan_depth = 0; > > - kasan_um_is_ready = true; > > + kasan_init_generic(); > > I think this runs before jump_label_init(), and static keys shouldn't be > switched before that.> }
I got the warning in my local compilation and from kernel CI [1]. arch/um places kasan_init() in own `.kasan_init` section, while kasan_init_generic() is called from __init. Could you suggest a way how I can verify the functions call order? I need to familiarize myself with how to run arch/um locally and try to fix this warning. [1] https://lore.kernel.org/all/caczwlxicmky4crdmabtn8m2cr2epumxlpqef5hk375cn2kv...@mail.gmail.com/ > > > > static void (*kasan_init_ptr)(void) >