Skip to content

[PW_SID:1094713] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe#1933

Open
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1094713
Open

[PW_SID:1094713] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe#1933
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw1094713

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 1094713 applied to workflow__riscv__fixes

Name: riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1094713
Version: 1

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 the absolute task stack boundary
(task_stack_page(task) + THREAD_SIZE) instead. This ensures that
once the frame pointer walks past the actual end of the stack,
the check consistently fails and the unwinding terminates.

Note that the frame pointer unwinder has no mechanism to detect
when the unwind has crossed from the task stack onto a different
kernel stack (e.g., IRQ stack). Using the absolute task stack
boundary provides correct protection against out-of-bounds reads
at the end of the task stack.

Fixes: a2a4d4a ("riscv: stacktrace: fixed walk_stackframe()")
Signed-off-by: Jiakai Xu <xujiakai2025@iscas.ac.cn>
Assisted-by: OpenClaw:DeepSeek-V3.2
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 114.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1114.13 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1636.67 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 19.35 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 21.04 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.59 seconds
Result: WARNING
Output:

CHECK: Unnecessary parentheses around 'regs->epc == pc'
#66: FILE: arch/riscv/kernel/stacktrace.c:87:
+		if (regs && (regs->epc == pc) && fp_is_valid(frame->ra, sp, task)) {

total: 0 errors, 0 warnings, 1 checks, 33 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 1d36b63744b7 ("riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 1 checks, 33 lines checked
CHECK: Unnecessary parentheses around 'regs->epc == pc'


@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 75.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
kdoc
Desc: Detects for kdoc errors
Duration: 0.71 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
module-param
Desc: Detect module_param changes
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.26 seconds
Result: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants