Borislav Petkov
4dba072cd0
x86/dumpstack: Explain the reasoning for the prologue and buffer size
...
The whole reasoning behind the amount of opcode bytes dumped and prologue
length isn't very clear so write down some of the reasons for why it is
done the way it is.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-10-bp@alien8.de
2018-04-26 16:15:28 +02:00
Borislav Petkov
602bd705da
x86/dumpstack: Save first regs set for the executive summary
...
Save the regs set when __die() is onvoked for the first time and print it
in oops_end().
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-9-bp@alien8.de
2018-04-26 16:15:28 +02:00
Borislav Petkov
7cccf0725c
x86/dumpstack: Add a show_ip() function
...
... which shows the Instruction Pointer along with the insn bytes around
it. Use it whenever rIP is printed. Drop the rIP < PAGE_OFFSET check since
probe_kernel_read() can handle any address properly.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-8-bp@alien8.de
2018-04-26 16:15:27 +02:00
Borislav Petkov
e8b6f98451
x86/dumpstack: Add loglevel argument to show_opcodes()
...
Will be used in the next patch.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-6-bp@alien8.de
2018-04-26 16:15:26 +02:00
Borislav Petkov
9e4a90fd34
x86/dumpstack: Improve opcodes dumping in the code section
...
The code used to iterate byte-by-byte over the bytes around RIP and that
is expensive: disabling pagefaults around it, copy_from_user, etc...
Make it read the whole buffer of OPCODE_BUFSIZE size in one go. Use a
statically allocated 64 bytes buffer so that concurrent show_opcodes()
do not interleave in the output even though in the majority of the cases
it's serialized via die_lock. Except the #PF path which doesn't...
Also, do the PAGE_OFFSET check outside of the function because latter
will be reused in other context.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-5-bp@alien8.de
2018-04-26 16:15:26 +02:00
Borislav Petkov
f0a1d7c11c
x86/dumpstack: Carve out code-dumping into a function
...
No functionality change, carve it out into a separate function for later
changes.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-4-bp@alien8.de
2018-04-26 16:15:26 +02:00
Borislav Petkov
5df61707f0
x86/dumpstack: Unexport oops_begin()
...
The only user outside of arch/ is not a module since
86cd47334b ("ACPI, APEI, GHES, Prevent GHES to be built as module")
No functional changes.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-3-bp@alien8.de
2018-04-26 16:15:26 +02:00
Borislav Petkov
5d12f0424e
x86/dumpstack: Remove code_bytes
...
This was added by
86c4183742 ("[PATCH] i386: add option to show more code in oops reports")
long time ago but experience shows that 64 instruction bytes are plenty
when deciphering an oops. So get rid of it.
Removing it will simplify further enhancements to the opcodes dumping
machinery coming in the following patches.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180417161124.5294-2-bp@alien8.de
2018-04-26 16:15:25 +02:00
Borislav Petkov
16d1cb0bc4
x86/dumpstack: Unify show_regs()
...
The 32-bit version uses KERN_EMERG and commit
b0f4c4b32c ("bugs, x86: Fix printk levels for panic, softlockups and stack dumps")
changed the 64-bit version to KERN_DEFAULT. The same justification in
that commit that those messages do not belong in the terminal, holds
true for 32-bit also, so make it so.
Make code_bytes static, while at it.
Signed-off-by: Borislav Petkov <bp@suse.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Andy Lutomirski <luto@amacapital.net >
Link: https://lkml.kernel.org/r/20180306094920.16917-4-bp@alien8.de
2018-03-08 12:04:59 +01:00
Arnd Bergmann
ebfc15019c
x86/dumpstack: Avoid uninitlized variable
...
In some configurations, 'partial' does not get initialized, as shown by
this gcc-8 warning:
arch/x86/kernel/dumpstack.c: In function 'show_trace_log_lvl':
arch/x86/kernel/dumpstack.c:156:4: error: 'partial' may be used uninitialized in this function [-Werror=maybe-uninitialized]
show_regs_if_on_stack(&stack_info, regs, partial);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This initializes it to false, to get the previous behavior in this case.
Fixes: a9cdbe72c4 ("x86/dumpstack: Fix partial register dumps")
Signed-off-by: Arnd Bergmann <arnd@arndb.de >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Nicolas Pitre <nico@linaro.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Borislav Petkov <bpetkov@suse.de >
Cc: Vlastimil Babka <vbabka@suse.cz >
Link: https://lkml.kernel.org/r/20180202145634.200291-1-arnd@arndb.de
2018-02-02 23:33:50 +01:00
Josh Poimboeuf
3ffdeb1a02
x86/dumpstack: Print registers for first stack frame
...
In the stack dump code, if the frame after the starting pt_regs is also
a regs frame, the registers don't get printed. Fix that.
Reported-by: Andy Lutomirski <luto@amacapital.net >
Tested-by: Alexander Tsoy <alexander@tsoy.me >
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Toralf Förster <toralf.foerster@gmx.de >
Cc: stable@vger.kernel.org
Fixes: 3b3fa11bc7 ("x86/dumpstack: Print any pt_regs found on the stack")
Link: http://lkml.kernel.org/r/396f84491d2f0ef64eda4217a2165f5712f6a115.1514736742.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2018-01-03 16:14:46 +01:00
Josh Poimboeuf
a9cdbe72c4
x86/dumpstack: Fix partial register dumps
...
The show_regs_safe() logic is wrong. When there's an iret stack frame,
it prints the entire pt_regs -- most of which is random stack data --
instead of just the five registers at the end.
show_regs_safe() is also poorly named: the on_stack() checks aren't for
safety. Rename the function to show_regs_if_on_stack() and add a
comment to explain why the checks are needed.
These issues were introduced with the "partial register dump" feature of
the following commit:
b02fcf9ba1 ("x86/unwinder: Handle stack overflows more gracefully")
That patch had gone through a few iterations of development, and the
above issues were artifacts from a previous iteration of the patch where
'regs' pointed directly to the iret frame rather than to the (partially
empty) pt_regs.
Tested-by: Alexander Tsoy <alexander@tsoy.me >
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: Toralf Förster <toralf.foerster@gmx.de >
Cc: stable@vger.kernel.org
Fixes: b02fcf9ba1 ("x86/unwinder: Handle stack overflows more gracefully")
Link: http://lkml.kernel.org/r/5b05b8b344f59db2d3d50dbdeba92d60f2304c54.1514736742.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2018-01-03 16:14:46 +01:00
Vlastimil Babka
5f26d76c3f
x86/dumpstack: Indicate in Oops whether PTI is configured and enabled
...
CONFIG_PAGE_TABLE_ISOLATION is relatively new and intrusive feature that may
still have some corner cases which could take some time to manifest and be
fixed. It would be useful to have Oops messages indicate whether it was
enabled for building the kernel, and whether it was disabled during boot.
Example of fully enabled:
Oops: 0001 [#1 ] SMP PTI
Example of enabled during build, but disabled during boot:
Oops: 0001 [#1 ] SMP NOPTI
We can decide to remove this after the feature has been tested in the field
long enough.
[ tglx: Made it use boot_cpu_has() as requested by Borislav ]
Signed-off-by: Vlastimil Babka <vbabka@suse.cz >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Eduardo Valentin <eduval@amazon.com >
Acked-by: Dave Hansen <dave.hansen@intel.com >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Andy Lutomirsky <luto@kernel.org >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: bpetkov@suse.de
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: jkosina@suse.cz
Cc: keescook@google.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-23 21:13:01 +01:00
Thomas Gleixner
92a0f81d89
x86/cpu_entry_area: Move it out of the fixmap
...
Put the cpu_entry_area into a separate P4D entry. The fixmap gets too big
and 0-day already hit a case where the fixmap PTEs were cleared by
cleanup_highmap().
Aside of that the fixmap API is a pain as it's all backwards.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-22 20:13:05 +01:00
Dave Hansen
4fe2d8b11a
x86/entry: Rename SYSENTER_stack to CPU_ENTRY_AREA_entry_stack
...
If the kernel oopses while on the trampoline stack, it will print
"<SYSENTER>" even if SYSENTER is not involved. That is rather confusing.
The "SYSENTER" stack is used for a lot more than SYSENTER now. Give it a
better string to display in stack dumps, and rename the kernel code to
match.
Also move the 32-bit code over to the new naming even though it still uses
the entry stack only for SYSENTER.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Borislav Petkov <bp@suse.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-22 20:13:02 +01:00
Andy Lutomirski
0f9a48100f
x86/entry: Clean up the SYSENTER_stack code
...
The existing code was a mess, mainly because C arrays are nasty. Turn
SYSENTER_stack into a struct, add a helper to find it, and do all the
obvious cleanups this enables.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bpetkov@suse.de >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@intel.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Eduardo Valentin <eduval@amazon.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Link: https://lkml.kernel.org/r/20171204150606.653244723@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-17 14:27:51 +01:00
Andy Lutomirski
7fbbd5cbeb
x86/entry/64: Remove the SYSENTER stack canary
...
Now that the SYSENTER stack has a guard page, there's no need for a canary
to detect overflow after the fact.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Borislav Petkov <bpetkov@suse.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@intel.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Eduardo Valentin <eduval@amazon.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Link: https://lkml.kernel.org/r/20171204150606.572577316@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-17 14:27:51 +01:00
Andy Lutomirski
72f5e08dbb
x86/entry: Remap the TSS into the CPU entry area
...
This has a secondary purpose: it puts the entry stack into a region
with a well-controlled layout. A subsequent patch will take
advantage of this to streamline the SYSCALL entry code to be able to
find it more easily.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bpetkov@suse.de >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@intel.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Eduardo Valentin <eduval@amazon.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Link: https://lkml.kernel.org/r/20171204150605.962042855@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-17 13:59:56 +01:00
Andy Lutomirski
6e60e58342
x86/dumpstack: Handle stack overflow on all stacks
...
We currently special-case stack overflow on the task stack. We're
going to start putting special stacks in the fixmap with a custom
layout, so they'll have guard pages, too. Teach the unwinder to be
able to unwind an overflow of any of the stacks.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Borislav Petkov <bpetkov@suse.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@intel.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Eduardo Valentin <eduval@amazon.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Link: https://lkml.kernel.org/r/20171204150605.802057305@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-17 13:59:55 +01:00
Andy Lutomirski
33a2f1a6c4
x86/dumpstack: Add get_stack_info() support for the SYSENTER stack
...
get_stack_info() doesn't currently know about the SYSENTER stack, so
unwinding will fail if we entered the kernel on the SYSENTER stack
and haven't fully switched off. Teach get_stack_info() about the
SYSENTER stack.
With future patches applied that run part of the entry code on the
SYSENTER stack and introduce an intentional BUG(), I would get:
PANIC: double fault, error_code: 0x0
...
RIP: 0010:do_error_trap+0x33/0x1c0
...
Call Trace:
Code: ...
With this patch, I get:
PANIC: double fault, error_code: 0x0
...
Call Trace:
<SYSENTER>
? async_page_fault+0x36/0x60
? invalid_op+0x22/0x40
? async_page_fault+0x36/0x60
? sync_regs+0x3c/0x40
? sync_regs+0x2e/0x40
? error_entry+0x6c/0xd0
? async_page_fault+0x36/0x60
</SYSENTER>
Code: ...
which is a lot more informative.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bp@suse.de >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Borislav Petkov <bpetkov@suse.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@intel.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Eduardo Valentin <eduval@amazon.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Link: https://lkml.kernel.org/r/20171204150605.392711508@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-17 13:59:54 +01:00
Josh Poimboeuf
b02fcf9ba1
x86/unwinder: Handle stack overflows more gracefully
...
There are at least two unwinder bugs hindering the debugging of
stack-overflow crashes:
- It doesn't deal gracefully with the case where the stack overflows and
the stack pointer itself isn't on a valid stack but the
to-be-dereferenced data *is*.
- The ORC oops dump code doesn't know how to print partial pt_regs, for the
case where if we get an interrupt/exception in *early* entry code
before the full pt_regs have been saved.
Fix both issues.
http://lkml.kernel.org/r/20171126024031.uxi4numpbjm5rlbr@treble
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com >
Signed-off-by: Thomas Gleixner <tglx@linutronix.de >
Reviewed-by: Borislav Petkov <bpetkov@suse.de >
Cc: Andy Lutomirski <luto@kernel.org >
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Dave Hansen <dave.hansen@intel.com >
Cc: Dave Hansen <dave.hansen@linux.intel.com >
Cc: David Laight <David.Laight@aculab.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: Eduardo Valentin <eduval@amazon.com >
Cc: Greg KH <gregkh@linuxfoundation.org >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Juergen Gross <jgross@suse.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Rik van Riel <riel@redhat.com >
Cc: Will Deacon <will.deacon@arm.com >
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Link: https://lkml.kernel.org/r/20171204150605.071425003@linutronix.de
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-12-17 13:59:52 +01:00
Andy Lutomirski
99504819fc
x86/asm/32: Remove a bunch of '& 0xffff' from pt_regs segment reads
...
Now that pt_regs properly defines segment fields as 16-bit on 32-bit
CPUs, there's no need to mask off the high word.
Signed-off-by: Andy Lutomirski <luto@kernel.org >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Borislav Petkov <bpetkov@suse.de >
Cc: Brian Gerst <brgerst@gmail.com >
Cc: Denys Vlasenko <dvlasenk@redhat.com >
Cc: H. Peter Anvin <hpa@zytor.com >
Cc: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-07-30 12:04:41 +02:00
Josh Poimboeuf
b0529beceb
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: 3b3fa11bc7 ("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 >
2017-07-18 10:56:23 +02:00
Josh Poimboeuf
e335bb51cc
x86/unwind: Ensure stack pointer is aligned
...
With frame pointers disabled, on some older versions of GCC (like
4.8.3), it's possible for the stack pointer to get aligned at a
half-word boundary:
00000000000004d0 <fib_table_lookup>:
4d0: 41 57 push %r15
4d2: 41 56 push %r14
4d4: 41 55 push %r13
4d6: 41 54 push %r12
4d8: 55 push %rbp
4d9: 53 push %rbx
4da: 48 83 ec 24 sub $0x24,%rsp
In such a case, the unwinder ends up reading the entire stack at the
wrong alignment. Then the last read goes past the end of the stack,
hitting the stack guard page:
BUG: stack guard page was hit at ffffc900217c4000 (stack is ffffc900217c0000..ffffc900217c3fff)
kernel stack overflow (page fault): 0000 [#1 ] SMP
...
Fix it by ensuring the stack pointer is properly aligned before
unwinding.
Reported-by: Jirka Hladky <jhladky@redhat.com >
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com >
Acked-by: Thomas Gleixner <tglx@linutronix.de >
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: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Fixes: 7c7900f897 ("x86/unwind: Add new unwind interface and implementations")
Link: http://lkml.kernel.org/r/cff33847cc9b02fa548625aa23268ac574460d8d.1492436590.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-04-18 10:30:23 +02:00
Peter Zijlstra
9a93848fe7
x86/debug: Implement __WARN() using UD0
...
By using "UD0" for WARN()s we remove the function call and its possible
__FILE__ and __LINE__ immediate arguments from the instruction stream.
Total image size will not change much, what we win in the instruction
stream we'll lose because of the __bug_table entries. Still, saves on
I$ footprint and the total image size does go down a bit.
text data filename
10702123 4530992 defconfig-build/vmlinux.orig
10682460 4530992 defconfig-build/vmlinux.patched
(UML didn't seem to use GENERIC_BUG at all, so remove it)
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org >
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com >
Cc: Arjan van de Ven <arjan@linux.intel.com >
Cc: Borislav Petkov <bp@alien8.de >
Cc: Linus Torvalds <torvalds@linux-foundation.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Richard Weinberger <richard.weinberger@gmail.com >
Cc: Thomas Gleixner <tglx@linutronix.de >
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org >
2017-03-27 10:20:28 +02:00