ARM: entry: use byte load for KASAN VMAP stack shadow
Subsystems (2)
PATCH 1/1 ARM: entry: use byte load for KASAN VMAP stack shadow
Commit 44e9a3bb76e5 ("ARM: 9430/1: entry: Do a dummy read from VMAP shadow") added a dummy read from the KASAN VMAP stack shadow in __switch_to(). The read uses ldr, but KASAN shadow memory is byte-granular and the computed shadow address is not guaranteed to be word aligned.
Booting the QEMU versatilepb machine with an ARM926EJ-S CPU and CONFIG_KASAN=y, CONFIG_KASAN_VMALLOC=y and CONFIG_VMAP_STACK=y faults before init:
Unhandled fault: alignment exception (0x001) at 0xb91037f6 PC is at __switch_to+0x64/0x88
Use ldrb for the dummy shadow access. The code only needs to fault if the shadow mapping is missing, so a byte load is sufficient and matches the granularity of KASAN shadow memory.
--- arch/arm/kernel/entry-armv.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/kernel/entry-armv.S +1 -1
@@ -567,7 +567,7 @@ ENTRY(__switch_to) @ are using KASAN mov_l r2, KASAN_SHADOW_OFFSET add r2, r2, ip, lsr #KASAN_SHADOW_SCALE_SHIFT - ldr r2, [r2] + ldrb r2, [r2] #endif #endif
Signature · 1 line
2.39.5 (Apple Git-154)
Quoted 13 lines · Karl Mehltretter
Commit
44e9a3bb76e5("ARM: 9430/1: entry: Do a dummy read from VMAP shadow") added a dummy read from the KASAN VMAP stack shadow in__switch_to(). The read uses ldr, but KASAN shadow memory is byte-granular and the computed shadow address is not guaranteed to be word aligned.Booting the QEMU versatilepb machine with an ARM926EJ-S CPU and
CONFIG_KASAN=y,CONFIG_KASAN_VMALLOC=yandCONFIG_VMAP_STACK=yfaults before init:Unhandled fault: alignment exception (
0x001) at0xb91037f6PC is at__switch_to+0x64/0x88
Quoted 8 lines
Use ldrb for the dummy shadow access. The code only needs to fault if the shadow mapping is missing, so a byte load is sufficient and matches the granularity of KASAN shadow memory.
Fixes 44e9a3bb76e5 ("ARM: 9430/1: entry: Do a dummy read from VMAP shadow")Cc [email protected] # v6.13+Assisted-by Codex:gpt-5Signed-off-by Karl Mehltretter <[email protected]>
Good catch!
Please put this patch into Russell's patch tracker.
Yours,
Linus Walleij
Quoted 1 line · Linus Walleij
Please put this patch into Russell's patch tracker.
Done: https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9475/1
Thanks,
Karl