[PW_SID:1118797] [v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()#2175
[PW_SID:1118797] [v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()#2175linux-riscv-bot wants to merge 2 commits into
Conversation
The fp_is_valid() function uses ALIGN(sp, THREAD_SIZE) as the upper bound for the frame pointer check. This bound is calculated relative to the current sp and shifts upward when sp itself exceeds the valid stack region, allowing the unwinder to read past the end of the allocated task stack and triggering KASAN stack-out-of-bounds. Fix this by using absolute stack boundaries determined once before the unwind loop: - When sp is on the task stack, use the task's pt_regs as the upper bound. - When sp is on the overflow_stack (CONFIG_VMAP_STACK=y), use the overflow_stack's top as the boundary. - When sp is on the IRQ stack (CONFIG_IRQ_STACKS=y), use the IRQ stack's top as the boundary. - When sp is not on any known stack, warn and return. - For remote tasks (task != current), if sp is not on the task stack, warn and return since we cannot reliably determine the correct boundary from a different CPU's stacks. Fixes: a2a4d4a ("riscv: stacktrace: fixed walk_stackframe()") Signed-off-by: Jiakai Xu <xujiakai2025@iscas.ac.cn> Assisted-by: YuanSheng:DeepSeek-V3.2 Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
|
Patch 1: "[v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()" |
4d827ba to
89be0ce
Compare
PR for series 1118797 applied to workflow__riscv__fixes
Name: [v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1118797
Version: 4