[PW_SID:976286] kasan: unify kasan_arch_is_ready with kasan_enabled#579
[PW_SID:976286] kasan: unify kasan_arch_is_ready with kasan_enabled#579linux-riscv-bot wants to merge 12 commits into
Conversation
Historically, the runtime static key kasan_flag_enabled existed only for CONFIG_KASAN_HW_TAGS mode. Generic and SW_TAGS modes either relied on architecture-specific kasan_arch_is_ready() implementations or evaluated KASAN checks unconditionally, leading to code duplication. This patch unifies the approach by: 1. Moving kasan_flag_enabled declaration under CONFIG_KASAN (all modes) instead of only CONFIG_KASAN_HW_TAGS 2. Moving the static key definition to common.c for shared usage 3. Adding kasan_init_generic() function that enables the static key and handles initialization for Generic mode 4. Updating SW_TAGS mode to enable the unified static key 5. Removing the duplicate static key definition from HW_TAGS After this change, all KASAN modes use the same underlying static key infrastructure. The kasan_enabled() function now provides consistent runtime enable behavior across Generic, SW_TAGS, and HW_TAGS modes. This maintains a backward compatibility - existing architecture code continues to work unchanged, but now benefits from the unified runtime control mechanism. The architecture-specific kasan_arch_is_ready() implementations can be gradually replaced with calls to the new kasan_init_generic() function. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark KASAN initialized in CONFIG_KASAN_GENERIC mode, otherwise it's an inline stub, and the flag is enabled in kasan_init_sw_tags() or kasan_init_hw_tags(). Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark KASAN initialized in CONFIG_KASAN_GENERIC mode, otherwise it's an inline stub. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Note that arch/xtensa still uses "current" instead of "init_task" pointer in `current->kasan_depth = 0;` to enable error messages. I haven't changed this because I can't test the change. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Replace `kasan_arch_is_ready` with `kasan_enabled`. Delete the flag `kasan_early_stage` in favor of the global static key enabled via kasan_enabled(). printk banner is printed earlier right where `kasan_early_stage` was flipped, just to keep the same flow. Note that `init_task.kasan_depth = 0;` is called after `kasan_init_generic()`, which is different than in other arch `kasan_init()`. I've left this unchanged as I can't test it. Defer to loongarch maintainers. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Delete the key `kasan_um_is_ready` in favor of the global static flag in linux/kasan-enabled.h which is enabled with kasan_init_generic(). 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=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Also prints the banner from the single place. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Also prints the banner from the single place. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Also prints the banner from the single place. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Fixes: 55d77ba ("kasan: fix Oops due to missing calls to kasan_arch_is_ready()") Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Call kasan_init_generic() which enables the static flag to mark generic KASAN initialized, otherwise it's an inline stub. Also prints the banner from the single place. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Replace the existing kasan_arch_is_ready() calls with kasan_enabled(). Drop checks where the caller is already under kasan_enabled() condition. Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218315 Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes" |
|
Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init" |
|
Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init" |
|
Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init" |
|
Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init" |
|
Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init" |
|
Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init" |
|
Patch 9: "[v2,09/11] kasan/powerpc: call kasan_init_generic in kasan_init" |
|
Patch 9: "[v2,09/11] kasan/powerpc: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
|
Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled" |
a7cb30d to
d776861
Compare
PR for series 976286 applied to workflow__riscv__fixes
Name: kasan: unify kasan_arch_is_ready with kasan_enabled
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=976286
Version: 2