[PATCH v4 11/12] arch/um: don't initialize kasan if it's disabled

Baoquan He posted 12 patches 2 months, 1 week ago
[PATCH v4 11/12] arch/um: don't initialize kasan if it's disabled
Posted by Baoquan He 2 months, 1 week ago
And also do the kasan_arg_disabled chekcing before kasan_flag_enabled
enabling to make sure kernel parameter kasan=on|off has been parsed.

Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: linux-um@lists.infradead.org
---
 arch/um/kernel/mem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 39c4a7e21c6f..08cd012a6bb8 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -62,8 +62,11 @@ static unsigned long brk_end;
 
 void __init arch_mm_preinit(void)
 {
+#ifdef CONFIG_KASAN
 	/* Safe to call after jump_label_init(). Enables KASAN. */
-	kasan_init_generic();
+	if (!kasan_arg_disabled)
+		kasan_init_generic();
+#endif
 
 	/* clear the zero-page */
 	memset(empty_zero_page, 0, PAGE_SIZE);
-- 
2.41.0
Re: [PATCH v4 11/12] arch/um: don't initialize kasan if it's disabled
Posted by Johannes Berg 2 months, 1 week ago
On Fri, 2025-11-28 at 11:33 +0800, Baoquan He wrote:
> And also do the kasan_arg_disabled chekcing before kasan_flag_enabled
                                     ^^^^^^^^

typo

> enabling to make sure kernel parameter kasan=on|off has been parsed.

But I'm not sure how to understand that sentence.

And I have no idea what to do with this patch, with it being random CC
of the middle of the series.

johannes
Re: [PATCH v4 11/12] arch/um: don't initialize kasan if it's disabled
Posted by Baoquan He 2 months, 1 week ago
On 12/01/25 at 11:56am, Johannes Berg wrote:
> On Fri, 2025-11-28 at 11:33 +0800, Baoquan He wrote:
> > And also do the kasan_arg_disabled chekcing before kasan_flag_enabled
>                                      ^^^^^^^^
> 
> typo

Thanks, will fix.

> 
> > enabling to make sure kernel parameter kasan=on|off has been parsed.
> 
> But I'm not sure how to understand that sentence.
> 
> And I have no idea what to do with this patch, with it being random CC
> of the middle of the series.

Sorry for the inconvenience. I am worried several rounds of posting
could bomb receivers's mail box, so only add arch's mailing list to 
CC in each arch's relevant patch. The whole patchset can be found at
below link. And the whole patchset are sent to linux-mm, lkml and kexec
mailing lists if subscribed any of them.

[PATCH v4 00/12] mm/kasan: make kasan=on|off work for all three modes
https://lore.kernel.org/all/20251128033320.1349620-1-bhe@redhat.com/T/#u

Thanks
Baoquan