From: Nam Cao <namcao@linutronix.de>
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>,
Jiakai Xu <xujiakai2025@iscas.ac.cn>,
Matthew Bystrin <dev.mbstr@gmail.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <pjw@kernel.org>, Rui Qi <qirui.001@bytedance.com>,
Samuel Holland <samuel.holland@sifive.com>,
Jiakai Xu <jiakaiPeanut@gmail.com>
Subject: Re: [PATCH v3] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()
Date: Sat, 27 Jun 2026 13:59:10 +0200 [thread overview]
Message-ID: <87zf0g42k1.fsf@yellow.woof> (raw)
In-Reply-To: <20260625123906.211981-1-xujiakai2025@iscas.ac.cn>
Jiakai Xu <xujiakai2025@iscas.ac.cn> writes:
> +#ifdef CONFIG_IRQ_STACKS
> +DECLARE_PER_CPU(ulong *, irq_stack_ptr);
> +#endif
Instead of this, shouldn't we
#include <asm/irq_stack.h>
?
> + if (sp >= (unsigned long)task_stack_page(task) &&
> + sp < (unsigned long)task_stack_page(task) + THREAD_SIZE) {
> + high = (unsigned long)task_pt_regs(task);
> + } else if (IS_ENABLED(CONFIG_IRQ_STACKS)) {
> + high = (unsigned long)this_cpu_read(irq_stack_ptr) +
> + IRQ_STACK_SIZE;
I suspect this fails to build if CONFIG_IRQ_STACKS=n, which would be
resolved if we do the suggested #include above.
> + } else {
> + high = (unsigned long)task_pt_regs(task);
We only get to this branch if the stack pointer is broken, right? If so,
I think printing a warning and returning is more appropriate.
Nam
WARNING: multiple messages have this Message-ID (diff)
From: Nam Cao <namcao@linutronix.de>
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>,
Jiakai Xu <xujiakai2025@iscas.ac.cn>,
Matthew Bystrin <dev.mbstr@gmail.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <pjw@kernel.org>, Rui Qi <qirui.001@bytedance.com>,
Samuel Holland <samuel.holland@sifive.com>,
Jiakai Xu <jiakaiPeanut@gmail.com>
Subject: Re: [PATCH v3] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()
Date: Sat, 27 Jun 2026 13:59:10 +0200 [thread overview]
Message-ID: <87zf0g42k1.fsf@yellow.woof> (raw)
In-Reply-To: <20260625123906.211981-1-xujiakai2025@iscas.ac.cn>
Jiakai Xu <xujiakai2025@iscas.ac.cn> writes:
> +#ifdef CONFIG_IRQ_STACKS
> +DECLARE_PER_CPU(ulong *, irq_stack_ptr);
> +#endif
Instead of this, shouldn't we
#include <asm/irq_stack.h>
?
> + if (sp >= (unsigned long)task_stack_page(task) &&
> + sp < (unsigned long)task_stack_page(task) + THREAD_SIZE) {
> + high = (unsigned long)task_pt_regs(task);
> + } else if (IS_ENABLED(CONFIG_IRQ_STACKS)) {
> + high = (unsigned long)this_cpu_read(irq_stack_ptr) +
> + IRQ_STACK_SIZE;
I suspect this fails to build if CONFIG_IRQ_STACKS=n, which would be
resolved if we do the suggested #include above.
> + } else {
> + high = (unsigned long)task_pt_regs(task);
We only get to this branch if the stack pointer is broken, right? If so,
I think printing a warning and returning is more appropriate.
Nam
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-06-27 11:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-25 12:39 [PATCH v3] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe() Jiakai Xu
2026-06-25 12:39 ` Jiakai Xu
2026-06-27 11:59 ` Nam Cao [this message]
2026-06-27 11:59 ` Nam Cao
2026-06-30 8:45 ` Jiakai Xu
2026-06-30 8:45 ` Jiakai Xu
2026-06-28 19:02 ` XIAO WU
2026-06-28 19:02 ` XIAO WU
2026-06-30 8:50 ` Jiakai Xu
2026-06-30 8:50 ` Jiakai Xu
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=87zf0g42k1.fsf@yellow.woof \
--to=namcao@linutronix.de \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=dev.mbstr@gmail.com \
--cc=jiakaiPeanut@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=qirui.001@bytedance.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.