[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACzwLxiD98BLmEmPhkJQgv297bP_7qw+Vm_icFhTiDYN7WvLjw@mail.gmail.com>
Date: Tue, 22 Jul 2025 19:17:03 +0500
From: Sabyrzhan Tasbolatov <snovitoll@...il.com>
To: Andrey Ryabinin <ryabinin.a.a@...il.com>
Cc: hca@...ux.ibm.com, christophe.leroy@...roup.eu, andreyknvl@...il.com,
agordeev@...ux.ibm.com, akpm@...ux-foundation.org, glider@...gle.com,
dvyukov@...gle.com, kasan-dev@...glegroups.com, linux-kernel@...r.kernel.org,
loongarch@...ts.linux.dev, linuxppc-dev@...ts.ozlabs.org,
linux-riscv@...ts.infradead.org, linux-s390@...r.kernel.org,
linux-um@...ts.infradead.org, linux-mm@...ck.org
Subject: Re: [PATCH v3 08/12] kasan/um: select ARCH_DEFER_KASAN and call kasan_init_generic
On Tue, Jul 22, 2025 at 4:00 AM Andrey Ryabinin <ryabinin.a.a@...il.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 <snovitoll@...il.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/CACzwLxicmky4CRdmABtN8m2cr2EpuMxLPqeF5Hk375cN2Kvu-Q@mail.gmail.com/
> >
> > static void (*kasan_init_ptr)(void)
>
Powered by blists - more mailing lists