When the unwinder reaches handle_interruption() or intr_return, it reads the interrupted context's sp and pc from the pt_regs just below the frame. That only holds for an interruption from kernel space. For one from user space, get_stack_use_cr30 saves the registers in task->thread.regs and starts the kernel stack PT_SZ_ALGN bytes above the base of the stack, so the unwinder reads whatever stale data is at the base of the stack. dump_stack() from such a trap then unwinds through a bogus frame into stale frames left on the stack, and repeats them: Backtrace: ... handle_interruption+0x674/0x106c __cmpxchg_u64+0x118/0x170 unwind_once+0x30/0x74 do_show_stack+0x10c/0x170 show_stack+0x68/0x80 dump_stack_lvl+0x1a8/0x260 dump_stack+0x34/0x48 check_preemption_disabled+0x18c/0x194 __this_cpu_preempt_check+0x38/0x4c handle_interruption+0x674/0x106c __cmpxchg_u64+0x118/0x170 ... On a C8000 with lockdep enabled, this left one CPU unwinding forever and the other CPUs soft-locked in smp_call_function_many_cond(). End the unwind when the pt_regs would sit at the base of the stack. Fixes: 05dc16d6a175 ("[PARISC] unwinder improvements") Fixes: c8921d72e390 ("parisc: Fix and improve kernel stack unwinding") Cc: stable@vger.kernel.org Signed-off-by: Matt Turner --- arch/parisc/kernel/unwind.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/parisc/kernel/unwind.c b/arch/parisc/kernel/unwind.c index fab9ae22191a..5f129c5d6e07 100644 --- a/arch/parisc/kernel/unwind.c +++ b/arch/parisc/kernel/unwind.c @@ -211,6 +211,19 @@ static bool pc_is_kernel_fn(unsigned long pc, void *fn) return (unsigned long)dereference_kernel_function_descriptor(fn) == pc; } +/* + * An interruption from user space saves its registers in the task struct + * and starts the kernel stack PT_SZ_ALGN bytes above the base of the + * stack, leaving stale data where a pt_regs would be. End the unwind there. + */ +static bool unwind_stop_at_user_regs(struct unwind_frame_info *info, struct pt_regs *regs) +{ + if ((unsigned long)regs != (unsigned long)task_stack_page(info->t)) + return false; + info->prev_sp = info->prev_ip = 0; + return true; +} + static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int frame_size) { /* @@ -231,6 +244,8 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int if (pc_is_kernel_fn(pc, handle_interruption)) { struct pt_regs *regs = (struct pt_regs *)(info->sp - frame_size - PT_SZ_ALGN); dbg("Unwinding through handle_interruption()\n"); + if (unwind_stop_at_user_regs(info, regs)) + return 1; info->prev_sp = regs->gr[30]; info->prev_ip = regs->iaoq[0]; return 1; @@ -247,6 +262,8 @@ static int unwind_special(struct unwind_frame_info *info, unsigned long pc, int dbg("Found intr_return()\n"); regs = (struct pt_regs *)(info->sp - PT_SZ_ALGN); + if (unwind_stop_at_user_regs(info, regs)) + return 1; info->prev_sp = regs->gr[30]; info->prev_ip = regs->iaoq[0]; info->rp = regs->gr[2]; -- 2.56.1