Re: [PATCH v4 6/9] kasan/um: select ARCH_DEFER_KASAN and call kasan_init_generic
From: Sabyrzhan Tasbolatov <hidden>
Date: 2025-08-06 04:35:57
Also in:
linux-mm, linux-riscv, linux-s390, linux-um, lkml, loongarch
On Tue, Aug 5, 2025 at 10:19 PM Andrey Ryabinin [off-list ref] wrote:
On 8/5/25 4:26 PM, Sabyrzhan Tasbolatov wrote:quoted
diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 9083bfdb773..8d14c8fc2cd 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig@@ -5,6 +5,7 @@ menu "UML-specific options" config UML bool default y + select ARCH_DEFER_KASANselect ARCH_DEFER_KASAN if STATIC_LINK
As pointed out in commit 5b301409e8bc("UML: add support for KASAN
under x86_64"),
: Also note that, while UML supports both KASAN in inline mode
(CONFIG_KASAN_INLINE)
: and static linking (CONFIG_STATIC_LINK), it does not support both at
the same time.
I've tested that for UML,
ARCH_DEFER_KASAN works if STATIC_LINK && KASAN_OUTLINE
ARCH_DEFER_KASAN works if KASAN_INLINE && !STATIC_LINK
ARCH_DEFER_KASAN if STATIC_LINK, and KASAN_INLINE=y by default from defconfig
crashes with SEGFAULT here (I didn't understand what it is, I think
the main() constructors
is not prepared in UML):
► 0 0x609d6f87 strlen+43
1 0x60a20db0 _dl_new_object+48
2 0x60a24627 _dl_non_dynamic_init+103
3 0x60a25f9a __libc_init_first+42
4 0x609eb6b2 __libc_start_main_impl+2434
5 0x6004a025 _start+37
Since this is the case only for UML, AFAIU, I don't think we want to change
conditions in lib/Kconfig.kasan. Shall I leave UML Kconfig as it is? e.g.
select ARCH_DEFER_KASAN
quoted
select ARCH_WANTS_DYNAMIC_TASK_STRUCT select ARCH_HAS_CACHE_LINE_SIZE select ARCH_HAS_CPU_FINALIZE_INITdiff --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 */