Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: Stop unwinding at start of stack

Check stack pointer if we are reaching the stack end and stop unwinding
if we do. This fixes early backtraces and avoids showing unrealistic
call stacks.

Signed-off-by: Helge Deller <deller@gmx.de>

+12
+12
arch/parisc/kernel/unwind.c
··· 14 14 #include <linux/slab.h> 15 15 #include <linux/kallsyms.h> 16 16 #include <linux/sort.h> 17 + #include <linux/sched.h> 17 18 18 19 #include <linux/uaccess.h> 19 20 #include <asm/assembly.h> ··· 280 279 281 280 info->prev_sp = sp - 64; 282 281 info->prev_ip = 0; 282 + 283 + /* The stack is at the end inside the thread_union 284 + * struct. If we reach data, we have reached the 285 + * beginning of the stack and should stop unwinding. */ 286 + if (info->prev_sp >= (unsigned long) task_thread_info(info->t) && 287 + info->prev_sp < ((unsigned long) task_thread_info(info->t) 288 + + THREAD_SZ_ALGN)) { 289 + info->prev_sp = 0; 290 + break; 291 + } 292 + 283 293 if (get_user(tmp, (unsigned long *)(info->prev_sp - RP_OFFSET))) 284 294 break; 285 295 info->prev_ip = tmp;