Merge tag 'edac_for_4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp
[sfrench/cifs-2.6.git] / arch / x86 / kernel / dumpstack.c
index ef8017ca5ba9dab6c59e51ae91b8c353ddaa00da..92e8f0a7159cadbafba6763081c2b33293be420a 100644 (file)
@@ -87,7 +87,7 @@ static inline int valid_stack_ptr(struct task_struct *task,
                else
                        return 0;
        }
-       return p > t && p < t + THREAD_SIZE - size;
+       return p >= t && p < t + THREAD_SIZE - size;
 }
 
 unsigned long
@@ -98,6 +98,14 @@ print_context_stack(struct task_struct *task,
 {
        struct stack_frame *frame = (struct stack_frame *)bp;
 
+       /*
+        * If we overflowed the stack into a guard page, jump back to the
+        * bottom of the usable stack.
+        */
+       if ((unsigned long)task_stack_page(task) - (unsigned long)stack <
+           PAGE_SIZE)
+               stack = (unsigned long *)task_stack_page(task);
+
        while (valid_stack_ptr(task, stack, sizeof(*stack), end)) {
                unsigned long addr;
 
@@ -197,6 +205,11 @@ void show_stack(struct task_struct *task, unsigned long *sp)
        show_stack_log_lvl(task, NULL, sp, bp, "");
 }
 
+void show_stack_regs(struct pt_regs *regs)
+{
+       show_stack_log_lvl(current, regs, (unsigned long *)regs->sp, regs->bp, "");
+}
+
 static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
 static int die_owner = -1;
 static unsigned int die_nest_count;
@@ -226,6 +239,8 @@ unsigned long oops_begin(void)
 EXPORT_SYMBOL_GPL(oops_begin);
 NOKPROBE_SYMBOL(oops_begin);
 
+void __noreturn rewind_stack_do_exit(int signr);
+
 void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
 {
        if (regs && kexec_should_crash(current))
@@ -247,7 +262,13 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
                panic("Fatal exception in interrupt");
        if (panic_on_oops)
                panic("Fatal exception");
-       do_exit(signr);
+
+       /*
+        * We're not going to return, but we might be on an IST stack or
+        * have very little stack space left.  Rewind the stack and kill
+        * the task.
+        */
+       rewind_stack_do_exit(signr);
 }
 NOKPROBE_SYMBOL(oops_end);