From: "Matthew Bystrin" <dev.mbstr@gmail.com>
To: "Jiakai Xu" <xujiakai2025@iscas.ac.cn>,
<linux-kernel@vger.kernel.org>, <linux-riscv@lists.infradead.org>
Cc: "Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Chunyan Zhang" <zhangchunyan@iscas.ac.cn>,
"Matthew Bystrin" <dev.mbstr@gmail.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Samuel Holland" <samuel.holland@sifive.com>
Subject: Re: [PATCH v2] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()
Date: Mon, 18 May 2026 23:37:39 +0300 [thread overview]
Message-ID: <DIM3B5ZM2WCI.27FLMTRS5IYNN@gmail.com> (raw)
In-Reply-To: <20260517143704.659416-1-xujiakai2025@iscas.ac.cn>
Hi!
> @@ -68,19 +68,24 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
> pc = task->thread.ra;
> }
>
> + if (!task)
> + task = current;
> +
> + high = (unsigned long)task_pt_regs(task);
After noticing end_of_stack() function I'm not sure task_pt_regs() is the best
candidate for the boundary. Let's see what maintainers are going to say.
> +
> for (;;) {
> struct stackframe *frame;
>
> if (unlikely(!__kernel_text_address(pc) || (level++ >= 0 && !fn(arg, pc))))
> break;
>
> - if (unlikely(!fp_is_valid(fp, sp)))
> + if (unlikely(!fp_is_valid(fp, sp, high)))
> break;
>
> /* Unwind stack frame */
> frame = (struct stackframe *)fp - 1;
> sp = fp;
> - if (regs && (regs->epc == pc) && fp_is_valid(frame->ra, sp)) {
> + if (regs && (regs->epc == pc) && fp_is_valid(frame->ra, sp, high)) {
> /* We hit function where ra is not saved on the stack */
> fp = frame->ra;
> pc = regs->ra;
> --
> 2.34.1
All in all looks fine.
Reviewed-by: Matthew Bystrin <dev.mbstr@gmail.com>
--
Best regards
Matt
next prev parent reply other threads:[~2026-05-18 20:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-17 14:37 [PATCH v2] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe() Jiakai Xu
2026-05-18 20:37 ` Matthew Bystrin [this message]
2026-06-19 9:11 ` Nam Cao
2026-06-12 1:41 ` Jiakai Xu
2026-06-19 9:51 ` Nam Cao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DIM3B5ZM2WCI.27FLMTRS5IYNN@gmail.com \
--to=dev.mbstr@gmail.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=xujiakai2025@iscas.ac.cn \
--cc=zhangchunyan@iscas.ac.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox