linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] mm/kasan: make kasan=on|off work for all three modes
@ 2025-08-05  6:23 Baoquan He
  2025-08-05  6:23 ` [PATCH 1/4] mm/kasan: add conditional checks in functions to return directly if kasan is disabled Baoquan He
                   ` (5 more replies)
  0 siblings, 6 replies; 21+ messages in thread
From: Baoquan He @ 2025-08-05  6:23 UTC (permalink / raw)
  To: linux-mm
  Cc: ryabinin.a.a, glider, andreyknvl, dvyukov, vincenzo.frascino,
	akpm, kasan-dev, linux-kernel, kexec, Baoquan He

Currently only hw_tags mode of kasan can be enabled or disabled with
kernel parameter kasan=on|off for built kernel. For kasan generic and
sw_tags mode, there's no way to disable them once kernel is built. 
This is not convenient sometime, e.g in system kdump is configured.
When the 1st kernel has KASAN enabled and crash triggered to switch to
kdump kernel, the generic or sw_tags mode will cost much extra memory
for kasan shadow while in fact it's meaningless to have kasan in kdump
kernel.

So this patchset moves the kasan=on|off out of hw_tags scope and into
common code to make it visible in generic and sw_tags mode too. Then we
can add kasan=off in kdump kernel to reduce the unneeded meomry cost for
kasan.

Test:
=====
I only took test on x86_64 for generic mode, and on arm64 for
generic, sw_tags and hw_tags mode. All of them works well.

However when I tested sw_tags on a HPE apollo arm64 machine, it always
breaks kernel with a KASAN bug. Even w/o this patchset applied, the bug 
can always be seen too.

"BUG: KASAN: invalid-access in pcpu_alloc_noprof+0x42c/0x9a8"

I haven't got root cause of the bug, will report the bug later in
another thread.
====

Baoquan He (4):
  mm/kasan: add conditional checks in functions to return directly if
    kasan is disabled
  mm/kasan: move kasan= code to common place
  mm/kasan: don't initialize kasan if it's disabled
  mm/kasan: make kasan=on|off take effect for all three modes

 arch/arm/mm/kasan_init.c               |  6 +++++
 arch/arm64/mm/kasan_init.c             |  7 ++++++
 arch/loongarch/mm/kasan_init.c         |  5 ++++
 arch/powerpc/mm/kasan/init_32.c        |  8 +++++-
 arch/powerpc/mm/kasan/init_book3e_64.c |  6 +++++
 arch/powerpc/mm/kasan/init_book3s_64.c |  6 +++++
 arch/riscv/mm/kasan_init.c             |  6 +++++
 arch/um/kernel/mem.c                   |  6 +++++
 arch/x86/mm/kasan_init_64.c            |  6 +++++
 arch/xtensa/mm/kasan_init.c            |  6 +++++
 include/linux/kasan-enabled.h          | 11 ++------
 mm/kasan/common.c                      | 27 ++++++++++++++++++++
 mm/kasan/generic.c                     | 20 +++++++++++++--
 mm/kasan/hw_tags.c                     | 35 ++------------------------
 mm/kasan/init.c                        |  6 +++++
 mm/kasan/quarantine.c                  |  3 +++
 mm/kasan/shadow.c                      | 23 ++++++++++++++++-
 mm/kasan/sw_tags.c                     |  9 +++++++
 18 files changed, 150 insertions(+), 46 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-08-12 17:07 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-05  6:23 [PATCH 0/4] mm/kasan: make kasan=on|off work for all three modes Baoquan He
2025-08-05  6:23 ` [PATCH 1/4] mm/kasan: add conditional checks in functions to return directly if kasan is disabled Baoquan He
2025-08-05  6:23 ` [PATCH 2/4] mm/kasan: move kasan= code to common place Baoquan He
2025-08-06  7:11   ` Marco Elver
2025-08-08 13:01     ` Baoquan He
2025-08-05  6:23 ` [PATCH 3/4] mm/kasan: don't initialize kasan if it's disabled Baoquan He
2025-08-05  6:23 ` [PATCH 4/4] mm/kasan: make kasan=on|off take effect for all three modes Baoquan He
2025-08-06  5:22   ` SeongJae Park
2025-08-06  9:36     ` Baoquan He
2025-08-06 16:26     ` Lorenzo Stoakes
2025-08-08 13:08       ` Baoquan He
2025-08-08 13:24         ` Lorenzo Stoakes
2025-08-12 13:27           ` Baoquan He
2025-08-12 17:06             ` Lorenzo Stoakes
2025-08-06 18:24   ` Sabyrzhan Tasbolatov
2025-08-08 15:59     ` Baoquan He
2025-08-06  7:16 ` [PATCH 0/4] mm/kasan: make kasan=on|off work " Marco Elver
2025-08-07 17:12   ` Andrey Ryabinin
2025-08-08  3:21   ` Baoquan He
2025-08-07 16:34 ` Andrey Ryabinin
2025-08-08 12:54   ` Baoquan He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).