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

x86/dumpstack: Fix occasionally missing registers

If two consecutive stack frames have pt_regs, the oops dump code fails
to print the second frame's registers. Fix that.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
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: Jiri Slaby <jslaby@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: live-patching@vger.kernel.org
Fixes: 3b3fa11bc700 ("x86/dumpstack: Print any pt_regs found on the stack")
Link: http://lkml.kernel.org/r/269c5c00c7d45c699f3dcea42a3a594c6cf7a9a3.1499786555.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
b0529bec 29955909

+7 -5
+7 -5
arch/x86/kernel/dumpstack.c
··· 94 94 if (stack_name) 95 95 printk("%s <%s>\n", log_lvl, stack_name); 96 96 97 + if (regs && on_stack(&stack_info, regs, sizeof(*regs))) 98 + __show_regs(regs, 0); 99 + 97 100 /* 98 101 * Scan the stack, printing any text addresses we find. At the 99 102 * same time, follow proper stack frames with the unwinder. ··· 121 118 * Don't print regs->ip again if it was already printed 122 119 * by __show_regs() below. 123 120 */ 124 - if (regs && stack == &regs->ip) { 125 - unwind_next_frame(&state); 126 - continue; 127 - } 121 + if (regs && stack == &regs->ip) 122 + goto next; 128 123 129 124 if (stack == ret_addr_p) 130 125 reliable = 1; ··· 145 144 if (!reliable) 146 145 continue; 147 146 147 + next: 148 148 /* 149 149 * Get the next frame from the unwinder. No need to 150 150 * check for an error: if anything goes wrong, the rest ··· 155 153 156 154 /* if the frame has entry regs, print them */ 157 155 regs = unwind_get_entry_regs(&state); 158 - if (regs) 156 + if (regs && on_stack(&stack_info, regs, sizeof(*regs))) 159 157 __show_regs(regs, 0); 160 158 } 161 159