* [PATCH] ARM: stacktrace: Fix Clang frame pointer upper bound and alignment check
@ 2026-11-30 23:24 Wei-chung Hsu
2026-12-01 3:31 ` Prasanna Kumar T S M
0 siblings, 1 reply; 2+ messages in thread
From: Wei-chung Hsu @ 2026-11-30 23:24 UTC (permalink / raw)
To: Russell King
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-arm-kernel, llvm, linux-kernel, Wei-chung Hsu
When built with Clang (CONFIG_CC_IS_CLANG) and frame pointers
(CONFIG_FRAME_POINTER), unwind_frame() reads two 32-bit words starting
at fp: *(unsigned long *)(fp) and *(unsigned long *)(fp + 4), i.e. 8
bytes [fp, fp + 7].
However, frame_pointer_check() copied the GCC upper-bound check
(fp > high - 4), which assumes accesses stay below fp (fp - 12 .. fp - 4).
It also does not verify 4-byte alignment of fp.
With CONFIG_VMAP_STACK=y, if an interrupt or lockdep trace_hardirqs_on()
unwinds through hand-written assembly that uses r11 (fp) as a scratch
pointer (such as __aes_arm_encrypt / __aes_arm_decrypt), an unaligned or
top-of-stack fp value in (high - 8, high - 4] (e.g. 0xf554bffb or
0xf6733ff9, 5-7 bytes below high) passes frame_pointer_check(), and the
subsequent read of *(unsigned long *)(fp + 4) faults into the unmapped
VMAP_STACK guard page:
Unable to handle kernel paging request at virtual address f554c000
Internal error: Oops: 207 [#1] SMP ARM
PC is at walk_stackframe+0x11c/0x17c
walk_stackframe from return_address+0x6c/0xa8
return_address from trace_hardirqs_on+0x158/0x1e8
trace_hardirqs_on from __aes_arm_encrypt+0x4b8/0x500
Reject unaligned frame pointers via !IS_ALIGNED(fp, 4) and tighten the
Clang upper bound to fp > high - 8 so both *(fp) and *(fp + 4) stay
strictly within [low, high).
Fixes: b4d5ec9b39f8 ("ARM: 8992/1: Fix unwind_frame for clang-built kernels")
Signed-off-by: Wei-chung Hsu <weihsu@google.com>
---
arch/arm/kernel/stacktrace.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 620aa82e3bdd..3cbab5286f10 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -64,8 +64,10 @@ static int frame_pointer_check(struct stackframe *frame)
high = ALIGN(low, THREAD_SIZE);
/* check current frame pointer is within bounds */
+ if (!IS_ALIGNED(fp, 4))
+ return -EINVAL;
#ifdef CONFIG_CC_IS_CLANG
- if (fp < low + 4 || fp > high - 4)
+ if (fp < low + 4 || fp > high - 8)
return -EINVAL;
#else
if (fp < low + 12 || fp > high - 4)
--
2.56.1.839.g22a8290db9-goog
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] ARM: stacktrace: Fix Clang frame pointer upper bound and alignment check
2026-11-30 23:24 [PATCH] ARM: stacktrace: Fix Clang frame pointer upper bound and alignment check Wei-chung Hsu
@ 2026-12-01 3:31 ` Prasanna Kumar T S M
0 siblings, 0 replies; 2+ messages in thread
From: Prasanna Kumar T S M @ 2026-12-01 3:31 UTC (permalink / raw)
To: Wei-chung Hsu, Russell King
Cc: Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
linux-arm-kernel, llvm, linux-kernel
On 01-12-2026 04:54, Wei-chung Hsu wrote:
> When built with Clang (CONFIG_CC_IS_CLANG) and frame pointers
> (CONFIG_FRAME_POINTER), unwind_frame() reads two 32-bit words starting
> at fp: *(unsigned long *)(fp) and *(unsigned long *)(fp + 4), i.e. 8
> bytes [fp, fp + 7].
>
> However, frame_pointer_check() copied the GCC upper-bound check
> (fp > high - 4), which assumes accesses stay below fp (fp - 12 .. fp - 4).
> It also does not verify 4-byte alignment of fp.
>
> With CONFIG_VMAP_STACK=y, if an interrupt or lockdep trace_hardirqs_on()
> unwinds through hand-written assembly that uses r11 (fp) as a scratch
> pointer (such as __aes_arm_encrypt / __aes_arm_decrypt), an unaligned or
> top-of-stack fp value in (high - 8, high - 4] (e.g. 0xf554bffb or
> 0xf6733ff9, 5-7 bytes below high) passes frame_pointer_check(), and the
> subsequent read of *(unsigned long *)(fp + 4) faults into the unmapped
> VMAP_STACK guard page:
>
> Unable to handle kernel paging request at virtual address f554c000
> Internal error: Oops: 207 [#1] SMP ARM
> PC is at walk_stackframe+0x11c/0x17c
> walk_stackframe from return_address+0x6c/0xa8
> return_address from trace_hardirqs_on+0x158/0x1e8
> trace_hardirqs_on from __aes_arm_encrypt+0x4b8/0x500
>
> Reject unaligned frame pointers via !IS_ALIGNED(fp, 4) and tighten the
> Clang upper bound to fp > high - 8 so both *(fp) and *(fp + 4) stay
> strictly within [low, high).
>
> Fixes: b4d5ec9b39f8 ("ARM: 8992/1: Fix unwind_frame for clang-built kernels")
> Signed-off-by: Wei-chung Hsu <weihsu@google.com>
> ---
> arch/arm/kernel/stacktrace.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
> index 620aa82e3bdd..3cbab5286f10 100644
> --- a/arch/arm/kernel/stacktrace.c
> +++ b/arch/arm/kernel/stacktrace.c
> @@ -64,8 +64,10 @@ static int frame_pointer_check(struct stackframe *frame)
> high = ALIGN(low, THREAD_SIZE);
>
> /* check current frame pointer is within bounds */
> + if (!IS_ALIGNED(fp, 4))
> + return -EINVAL;
> #ifdef CONFIG_CC_IS_CLANG
> - if (fp < low + 4 || fp > high - 4)
> + if (fp < low + 4 || fp > high - 8)
> return -EINVAL;
> #else
> if (fp < low + 12 || fp > high - 4)
Looks good to me.
Reviewed-by: Prasanna Kumar T S M <ptsm@linux.microsoft.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-01 3:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 23:24 [PATCH] ARM: stacktrace: Fix Clang frame pointer upper bound and alignment check Wei-chung Hsu
2026-12-01 3:31 ` Prasanna Kumar T S M
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®