public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH] ARM: entry: use byte load for KASAN VMAP stack shadow
@ 2026-05-22 21:15 Karl Mehltretter
  2026-05-23 22:08 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Karl Mehltretter @ 2026-05-22 21:15 UTC (permalink / raw)
  To: Russell King
  Cc: Linus Walleij, Russell King (Oracle), linux-arm-kernel,
	linux-kernel, stable, 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=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.

Fixes: 44e9a3bb76e5 ("ARM: 9430/1: entry: Do a dummy read from VMAP shadow")
Cc: stable@vger•kernel.org # v6.13+
Assisted-by: Codex:gpt-5
Signed-off-by: Karl Mehltretter <kmehltretter@gmail•com>
---
 arch/arm/kernel/entry-armv.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index ef6a657c8d13..a3d050ce9b79 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -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
 
-- 
2.39.5 (Apple Git-154)


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

* Re: [PATCH] ARM: entry: use byte load for KASAN VMAP stack shadow
  2026-05-22 21:15 [PATCH] ARM: entry: use byte load for KASAN VMAP stack shadow Karl Mehltretter
@ 2026-05-23 22:08 ` Linus Walleij
  2026-05-24  7:49   ` Karl Mehltretter
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2026-05-23 22:08 UTC (permalink / raw)
  To: Karl Mehltretter
  Cc: Russell King, Russell King (Oracle), linux-arm-kernel,
	linux-kernel, stable

On Fri, May 22, 2026 at 11:15 PM Karl Mehltretter
<kmehltretter@gmail•com> wrote:

> 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.
>
> Fixes: 44e9a3bb76e5 ("ARM: 9430/1: entry: Do a dummy read from VMAP shadow")
> Cc: stable@vger•kernel.org # v6.13+
> Assisted-by: Codex:gpt-5
> Signed-off-by: Karl Mehltretter <kmehltretter@gmail•com>

Good catch!
Reviewed-by: Linus Walleij <linusw@kernel•org>

Please put this patch into Russell's patch tracker.

Yours,
Linus Walleij


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

* Re: [PATCH] ARM: entry: use byte load for KASAN VMAP stack shadow
  2026-05-23 22:08 ` Linus Walleij
@ 2026-05-24  7:49   ` Karl Mehltretter
  0 siblings, 0 replies; 3+ messages in thread
From: Karl Mehltretter @ 2026-05-24  7:49 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Russell King, Russell King (Oracle), linux-arm-kernel,
	linux-kernel, stable

On Sun, May 24, 2026 at 12:08:57AM +0100, Linus Walleij wrote:
> Please put this patch into Russell's patch tracker.

Done: https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9475/1

Thanks,
Karl


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

end of thread, other threads:[~2026-05-24  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22 21:15 [PATCH] ARM: entry: use byte load for KASAN VMAP stack shadow Karl Mehltretter
2026-05-23 22:08 ` Linus Walleij
2026-05-24  7:49   ` Karl Mehltretter

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