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>
Subject: Re: [PATCH v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()
Date: Thu, 02 Jul 2026 10:05:52 +0200 [thread overview]
Message-ID: <87ik6xvmsf.fsf@yellow.woof> (raw)
In-Reply-To: <20260630090535.4103888-1-xujiakai2025@iscas.ac.cn>
Jiakai Xu <xujiakai2025@iscas.ac.cn> writes:
> + 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 (task != current) {
> + pr_warn("%s: sp (%lx) is not in task stack of %s\n",
> + __func__, sp, task->comm);
> + return;
> + }
> +#ifdef CONFIG_VMAP_STACK
> + else {
> + unsigned long ovf_base =
> + (unsigned long)this_cpu_ptr(overflow_stack);
> +
> + if (sp >= ovf_base && sp < ovf_base + OVERFLOW_STACK_SIZE)
> + high = ovf_base + OVERFLOW_STACK_SIZE;
> + }
> +#endif
Looks functionally correct to me. But this #ifdef goes against the
kernel's coding style. See:
https://docs.kernel.org/process/coding-style.html
Can we
else if (IS_ENABLED(CONFIG_VMAP_STACK))
just like the irq stack thing?
> + if (IS_ENABLED(CONFIG_IRQ_STACKS) && !high) {
> + unsigned long irq_base =
> + (unsigned long)this_cpu_read(irq_stack_ptr);
> +
> + if (sp >= irq_base && sp < irq_base + IRQ_STACK_SIZE)
> + high = irq_base + IRQ_STACK_SIZE;
> + }
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>
Subject: Re: [PATCH v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()
Date: Thu, 02 Jul 2026 10:05:52 +0200 [thread overview]
Message-ID: <87ik6xvmsf.fsf@yellow.woof> (raw)
In-Reply-To: <20260630090535.4103888-1-xujiakai2025@iscas.ac.cn>
Jiakai Xu <xujiakai2025@iscas.ac.cn> writes:
> + 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 (task != current) {
> + pr_warn("%s: sp (%lx) is not in task stack of %s\n",
> + __func__, sp, task->comm);
> + return;
> + }
> +#ifdef CONFIG_VMAP_STACK
> + else {
> + unsigned long ovf_base =
> + (unsigned long)this_cpu_ptr(overflow_stack);
> +
> + if (sp >= ovf_base && sp < ovf_base + OVERFLOW_STACK_SIZE)
> + high = ovf_base + OVERFLOW_STACK_SIZE;
> + }
> +#endif
Looks functionally correct to me. But this #ifdef goes against the
kernel's coding style. See:
https://docs.kernel.org/process/coding-style.html
Can we
else if (IS_ENABLED(CONFIG_VMAP_STACK))
just like the irq stack thing?
> + if (IS_ENABLED(CONFIG_IRQ_STACKS) && !high) {
> + unsigned long irq_base =
> + (unsigned long)this_cpu_read(irq_stack_ptr);
> +
> + if (sp >= irq_base && sp < irq_base + IRQ_STACK_SIZE)
> + high = irq_base + IRQ_STACK_SIZE;
> + }
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-07-02 8:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 9:05 [PATCH v4] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe() Jiakai Xu
2026-06-30 9:05 ` Jiakai Xu
2026-07-02 8:05 ` Nam Cao [this message]
2026-07-02 8:05 ` Nam Cao
2026-07-02 8:34 ` Jiakai Xu
2026-07-02 8:34 ` 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=87ik6xvmsf.fsf@yellow.woof \
--to=namcao@linutronix.de \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=dev.mbstr@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.