Re: [PATCH v3] riscv: stacktrace: fix stack-out-of-bounds in walk_stackframe()

From: Nam Cao

Date: Sat Jun 27 2026 - 07:59:16 EST


Jiakai Xu <xujiakai2025@xxxxxxxxxxx> 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