Skip to content

[PW_SID:976286] kasan: unify kasan_arch_is_ready with kasan_enabled#579

Closed
linux-riscv-bot wants to merge 12 commits into
workflow__riscv__fixesfrom
pw976286
Closed

[PW_SID:976286] kasan: unify kasan_arch_is_ready with kasan_enabled#579
linux-riscv-bot wants to merge 12 commits into
workflow__riscv__fixesfrom
pw976286

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

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

Linux RISC-V bot and others added 12 commits June 24, 2025 01:05
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>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 102.08 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 2006.46 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2700.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.02 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.59 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.68 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 71.64 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
kdoc
Desc: Detects for kdoc errors
Duration: 0.85 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[v2,01/11] kasan: unify static kasan_flag_enabled across modes"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 101.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 921.29 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1236.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.93 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.41 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[v2,02/11] kasan/arm64: call kasan_init_generic in kasan_init"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.65 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 9: "[v2,09/11] kasan/powerpc: call kasan_init_generic in kasan_init"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.28 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 9: "[v2,09/11] kasan/powerpc: call kasan_init_generic in kasan_init"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 101.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1007.62 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1471.89 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.57 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.50 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.69 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 70.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
kdoc
Desc: Detects for kdoc errors
Duration: 0.87 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 10: "[v2,10/11] kasan/riscv: call kasan_init_generic in kasan_init"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 102.10 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 2015.09 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 2720.05 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 20.17 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.75 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.51 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 71.03 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
kdoc
Desc: Detects for kdoc errors
Duration: 0.91 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 11: "[v2,11/11] kasan: replace kasan_arch_is_ready with kasan_enabled"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot force-pushed the workflow__riscv__fixes branch 2 times, most recently from a7cb30d to d776861 Compare July 2, 2025 18:46
@linux-riscv-bot linux-riscv-bot deleted the pw976286 branch July 4, 2025 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants