load_unaligned_zeropad() is inline assembly, so KASAN and KCSAN never see the word loads that sized_strscpy(), the dcache name compare, path name hashing and x86 csum_partial() do through it. While reviewing a strscpy() KASAN fix, Peter Collingbourne suggested checking the first byte inside load_unaligned_zeropad() itself, as read_word_at_a_time() does [1].
Patch 1 adds that check on the six architectures that implement load_unaligned_zeropad(). Patch 2 adds a KASAN KUnit case for it. This is independent of the strscpy() fix, which makes sized_strscpy() copy byte by byte under software KASAN so that every byte it reads is checked. Either can be applied without the other. [1] https://lore.kernel.org/r/capqlkrhxzwozmfhnd_pex1ihwdh1_5qthp6panyj_m-v9vf...@mail.gmail.com Signed-off-by: Qiliang Yuan <[email protected]> --- Qiliang Yuan (2): word-at-a-time: check the first byte in load_unaligned_zeropad() kasan/test: cover load_unaligned_zeropad() arch/arm/include/asm/word-at-a-time.h | 7 +++++++ arch/arm64/include/asm/word-at-a-time.h | 7 +++++++ arch/powerpc/include/asm/word-at-a-time.h | 6 ++++++ arch/riscv/include/asm/word-at-a-time.h | 6 ++++++ arch/s390/include/asm/word-at-a-time.h | 6 ++++++ arch/x86/include/asm/word-at-a-time.h | 6 ++++++ mm/kasan/kasan_test_c.c | 24 ++++++++++++++++++++++ .../powerpc/primitives/linux/kasan-checks.h | 3 +++ .../powerpc/primitives/linux/kcsan-checks.h | 3 +++ 9 files changed, 68 insertions(+) --- base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222 change-id: 20261019-bug-word-at-a-time-zeropad-kasan-af2460466ee6 Best regards, -- Qiliang Yuan <[email protected]>

