Skip to content

Commit 98f30b1

Browse files
amlutoIngo Molnar
authored andcommitted
x86/dumpstack/64: Handle faults when printing the "Stack: " part of an OOPS
If we overflow the stack into a guard page, we'll recursively fault when trying to dump the contents of the guard page. Use probe_kernel_address() so we can recover if this happens. Signed-off-by: Andy Lutomirski <luto@kernel.org> Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/e626d47a55d7b04dcb1b4d33faa95e8505b217c8.1468527351.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 9a2e9da commit 98f30b1

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

arch/x86/kernel/dumpstack_64.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
272272

273273
stack = sp;
274274
for (i = 0; i < kstack_depth_to_print; i++) {
275+
unsigned long word;
276+
275277
if (stack >= irq_stack && stack <= irq_stack_end) {
276278
if (stack == irq_stack_end) {
277279
stack = (unsigned long *) (irq_stack_end[-1]);
@@ -281,12 +283,18 @@ show_stack_log_lvl(struct task_struct *task, struct pt_regs *regs,
281283
if (kstack_end(stack))
282284
break;
283285
}
286+
287+
if (probe_kernel_address(stack, word))
288+
break;
289+
284290
if ((i % STACKSLOTS_PER_LINE) == 0) {
285291
if (i != 0)
286292
pr_cont("\n");
287-
printk("%s %016lx", log_lvl, *stack++);
293+
printk("%s %016lx", log_lvl, word);
288294
} else
289-
pr_cont(" %016lx", *stack++);
295+
pr_cont(" %016lx", word);
296+
297+
stack++;
290298
touch_nmi_watchdog();
291299
}
292300
preempt_enable();

0 commit comments

Comments
 (0)