mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/7] kasan: Add KUnit config and fix missing instrumentation in load_unaligned_zeropad()
@ 2026-09-11  7:03 Bill Wendling
  2026-09-11  7:03 ` [PATCH 1/7] kasan: Add .kunitconfig for KUnit tests Bill Wendling
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Bill Wendling @ 2026-09-11  7:03 UTC (permalink / raw)
  To: linux-kernel; +Cc: Bill Wendling

This series makes the KASAN KUnit test suite easy to run via kunit.py
and fixes a real detection gap it uncovered along the way.

Patch 1 adds mm/kasan/.kunitconfig so the suite can be run with:

    ./tools/testing/kunit/kunit.py run --arch=x86_64 --kunitconfig mm/kasan

Getting CONFIG_KASAN_KUNIT_TEST to actually build required pulling in
CONFIG_SCHED_TRACER (CONFIG_FTRACE alone doesn't select the invisible
TRACEPOINTS symbol it depends on), plus a larger CONFIG_LOG_BUF_SHIFT
to stop KASAN's verbose reports from overflowing the printk buffer
under QEMU.

The migration from read_word_at_a_time() to load_unaligned_zeropad() lost
instrumentation, because the load_unaligned_zeropad() functions are
implemented as inline asm with an exception table entry on every
architecture, so the compiler never sees the memory access and can't
instrument it for KASAN/KCSAN. This meant sized_strscpy() silently
bypassed KASAN when reading its source buffer word-at-a-time, and the
same gap turned out to be open at every other call site in the tree.

Rather than patching each call site individually, patch 2 renames
x86's load_unaligned_zeropad() to arch_load_unaligned_zeropad() and
adds a single common, always-inlined wrapper that instruments the read
before calling through.

Patches 3-7 convert the remaining architectures (arm64, arm, riscv,
s390, powerpc) that implement load_unaligned_zeropad() to the same
pattern, so each can be reviewed independently by its arch maintainer.

Verified via objdump that the wrapper adds no calls or relocations
when KASAN and KCSAN are both disabled.

Bill Wendling (7):
  kasan: Add .kunitconfig for KUnit tests
  x86/word-at-a-time: Instrument load_unaligned_zeropad()
  arm64/word-at-a-time: Instrument load_unaligned_zeropad()
  arm/word-at-a-time: Instrument load_unaligned_zeropad()
  riscv/word-at-a-time: Instrument load_unaligned_zeropad()
  s390/word-at-a-time: Instrument load_unaligned_zeropad()
  powerpc/word-at-a-time: Instrument load_unaligned_zeropad()

 arch/arm/include/asm/word-at-a-time.h         |  4 ++-
 arch/arm64/include/asm/word-at-a-time.h       |  4 ++-
 arch/powerpc/include/asm/word-at-a-time.h     |  4 ++-
 arch/riscv/include/asm/word-at-a-time.h       |  4 ++-
 arch/s390/include/asm/word-at-a-time.h        |  4 ++-
 arch/x86/include/asm/word-at-a-time.h         |  4 ++-
 .../asm-generic/word-at-a-time-instrumented.h | 25 +++++++++++++++++++
 mm/kasan/.kunitconfig                         | 15 +++++++++++
 8 files changed, 58 insertions(+), 6 deletions(-)
 create mode 100644 include/asm-generic/word-at-a-time-instrumented.h
 create mode 100644 mm/kasan/.kunitconfig

-- 
2.47.3


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

end of thread, other threads:[~2026-09-11  7:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-11  7:03 [PATCH 0/7] kasan: Add KUnit config and fix missing instrumentation in load_unaligned_zeropad() Bill Wendling
2026-09-11  7:03 ` [PATCH 1/7] kasan: Add .kunitconfig for KUnit tests Bill Wendling
2026-09-11  7:03 ` [PATCH 2/7] x86/word-at-a-time: Instrument load_unaligned_zeropad() Bill Wendling
2026-09-11  7:03 ` [PATCH 3/7] arm64/word-at-a-time: " Bill Wendling
2026-09-11  7:03 ` [PATCH 4/7] arm/word-at-a-time: " Bill Wendling
2026-09-11  7:03 ` [PATCH 5/7] riscv/word-at-a-time: " Bill Wendling
2026-09-11  7:03 ` [PATCH 6/7] s390/word-at-a-time: " Bill Wendling
2026-09-11  7:03 ` [PATCH 7/7] powerpc/word-at-a-time: " Bill Wendling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®