Re: [PATCH 1/9] kasan: unify static kasan_flag_enabled across modes

From: Christophe Leroy
Date: Wed Jun 25 2025 - 06:53:29 EST




Le 25/06/2025 à 11:52, Sabyrzhan Tasbolatov a écrit :
Historically the fast-path static key `kasan_flag_enabled` existed
only for `CONFIG_KASAN_HW_TAGS`. Generic and SW_TAGS either relied on
`kasan_arch_is_ready()` or evaluated KASAN checks unconditionally.
As a result every architecture had to toggle a private flag
in its `kasan_init()`.

This patch turns the flag into a single global runtime predicate that
is built for every `CONFIG_KASAN` mode and adds a helper that flips
the key once KASAN is ready.

Shouldn't kasan_init_generic() also perform the following line to reduce even more code duplication between architectures ?

init_task.kasan_depth = 0;

Christophe