浏览代码

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>
Helge Deller 8 年之前
父节点
当前提交
e77900abfd
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      arch/parisc/kernel/unwind.c

+ 12 - 0
arch/parisc/kernel/unwind.c

@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/slab.h>
 #include <linux/kallsyms.h>
 #include <linux/kallsyms.h>
 #include <linux/sort.h>
 #include <linux/sort.h>
+#include <linux/sched.h>
 
 
 #include <linux/uaccess.h>
 #include <linux/uaccess.h>
 #include <asm/assembly.h>
 #include <asm/assembly.h>
@@ -279,6 +280,17 @@ static void unwind_frame_regs(struct unwind_frame_info *info)
 
 
 			info->prev_sp = sp - 64;
 			info->prev_sp = sp - 64;
 			info->prev_ip = 0;
 			info->prev_ip = 0;
+
+			/* The stack is at the end inside the thread_union
+			 * struct. If we reach data, we have reached the
+			 * beginning of the stack and should stop unwinding. */
+			if (info->prev_sp >= (unsigned long) task_thread_info(info->t) &&
+			    info->prev_sp < ((unsigned long) task_thread_info(info->t)
+						+ THREAD_SZ_ALGN)) {
+				info->prev_sp = 0;
+				break;
+			}
+
 			if (get_user(tmp, (unsigned long *)(info->prev_sp - RP_OFFSET))) 
 			if (get_user(tmp, (unsigned long *)(info->prev_sp - RP_OFFSET))) 
 				break;
 				break;
 			info->prev_ip = tmp;
 			info->prev_ip = tmp;