| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- From 11739f104753550b4d256207c07a75f667b7aae4 Mon Sep 17 00:00:00 2001
- From: Andy Lutomirski <[email protected]>
- Date: Mon, 4 Dec 2017 15:07:18 +0100
- Subject: [PATCH 148/242] x86/dumpstack: Handle stack overflow on all stacks
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- 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 <[email protected]>
- Signed-off-by: Thomas Gleixner <[email protected]>
- Reviewed-by: Borislav Petkov <[email protected]>
- Cc: Boris Ostrovsky <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Brian Gerst <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: David Laight <[email protected]>
- Cc: Denys Vlasenko <[email protected]>
- Cc: Eduardo Valentin <[email protected]>
- Cc: Greg KH <[email protected]>
- Cc: H. Peter Anvin <[email protected]>
- Cc: Josh Poimboeuf <[email protected]>
- Cc: Juergen Gross <[email protected]>
- Cc: Linus Torvalds <[email protected]>
- Cc: Peter Zijlstra <[email protected]>
- Cc: Rik van Riel <[email protected]>
- Cc: Will Deacon <[email protected]>
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Link: https://lkml.kernel.org/r/[email protected]
- Signed-off-by: Ingo Molnar <[email protected]>
- (cherry picked from commit 6e60e583426c2f8751c22c2dfe5c207083b4483a)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit 1ab51120b9a5baaa46979e4ab8ff28916c9cb846)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/x86/kernel/dumpstack.c | 24 ++++++++++++++----------
- 1 file changed, 14 insertions(+), 10 deletions(-)
- diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
- index c211cbdff709..0f4b931e1a02 100644
- --- a/arch/x86/kernel/dumpstack.c
- +++ b/arch/x86/kernel/dumpstack.c
- @@ -112,24 +112,28 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
- * - task stack
- * - interrupt stack
- * - HW exception stacks (double fault, nmi, debug, mce)
- + * - SYSENTER stack
- *
- - * x86-32 can have up to three stacks:
- + * x86-32 can have up to four stacks:
- * - task stack
- * - softirq stack
- * - hardirq stack
- + * - SYSENTER stack
- */
- for (regs = NULL; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
- const char *stack_name;
-
- - /*
- - * If we overflowed the task stack into a guard page, jump back
- - * to the bottom of the usable stack.
- - */
- - if (task_stack_page(task) - (void *)stack < PAGE_SIZE)
- - stack = task_stack_page(task);
- -
- - if (get_stack_info(stack, task, &stack_info, &visit_mask))
- - break;
- + if (get_stack_info(stack, task, &stack_info, &visit_mask)) {
- + /*
- + * We weren't on a valid stack. It's possible that
- + * we overflowed a valid stack into a guard page.
- + * See if the next page up is valid so that we can
- + * generate some kind of backtrace if this happens.
- + */
- + stack = (unsigned long *)PAGE_ALIGN((unsigned long)stack);
- + if (get_stack_info(stack, task, &stack_info, &visit_mask))
- + break;
- + }
-
- stack_name = stack_type_name(stack_info.type);
- if (stack_name)
- --
- 2.14.2
|