]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0148-x86-dumpstack-Handle-stack-overflow-on-all-stacks.patch
b6b0e2a9b4cdaab83adf925f2ac0ebd34cd57d93
[pve-kernel.git] / patches / kernel / 0148-x86-dumpstack-Handle-stack-overflow-on-all-stacks.patch
1 From 11739f104753550b4d256207c07a75f667b7aae4 Mon Sep 17 00:00:00 2001
2 From: Andy Lutomirski <luto@kernel.org>
3 Date: Mon, 4 Dec 2017 15:07:18 +0100
4 Subject: [PATCH 148/241] x86/dumpstack: Handle stack overflow on all stacks
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2017-5754
10
11 We currently special-case stack overflow on the task stack. We're
12 going to start putting special stacks in the fixmap with a custom
13 layout, so they'll have guard pages, too. Teach the unwinder to be
14 able to unwind an overflow of any of the stacks.
15
16 Signed-off-by: Andy Lutomirski <luto@kernel.org>
17 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
18 Reviewed-by: Borislav Petkov <bp@suse.de>
19 Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
20 Cc: Borislav Petkov <bp@alien8.de>
21 Cc: Borislav Petkov <bpetkov@suse.de>
22 Cc: Brian Gerst <brgerst@gmail.com>
23 Cc: Dave Hansen <dave.hansen@intel.com>
24 Cc: Dave Hansen <dave.hansen@linux.intel.com>
25 Cc: David Laight <David.Laight@aculab.com>
26 Cc: Denys Vlasenko <dvlasenk@redhat.com>
27 Cc: Eduardo Valentin <eduval@amazon.com>
28 Cc: Greg KH <gregkh@linuxfoundation.org>
29 Cc: H. Peter Anvin <hpa@zytor.com>
30 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
31 Cc: Juergen Gross <jgross@suse.com>
32 Cc: Linus Torvalds <torvalds@linux-foundation.org>
33 Cc: Peter Zijlstra <peterz@infradead.org>
34 Cc: Rik van Riel <riel@redhat.com>
35 Cc: Will Deacon <will.deacon@arm.com>
36 Cc: aliguori@amazon.com
37 Cc: daniel.gruss@iaik.tugraz.at
38 Cc: hughd@google.com
39 Cc: keescook@google.com
40 Link: https://lkml.kernel.org/r/20171204150605.802057305@linutronix.de
41 Signed-off-by: Ingo Molnar <mingo@kernel.org>
42 (cherry picked from commit 6e60e583426c2f8751c22c2dfe5c207083b4483a)
43 Signed-off-by: Andy Whitcroft <apw@canonical.com>
44 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
45 (cherry picked from commit 1ab51120b9a5baaa46979e4ab8ff28916c9cb846)
46 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
47 ---
48 arch/x86/kernel/dumpstack.c | 24 ++++++++++++++----------
49 1 file changed, 14 insertions(+), 10 deletions(-)
50
51 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
52 index c211cbdff709..0f4b931e1a02 100644
53 --- a/arch/x86/kernel/dumpstack.c
54 +++ b/arch/x86/kernel/dumpstack.c
55 @@ -112,24 +112,28 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
56 * - task stack
57 * - interrupt stack
58 * - HW exception stacks (double fault, nmi, debug, mce)
59 + * - SYSENTER stack
60 *
61 - * x86-32 can have up to three stacks:
62 + * x86-32 can have up to four stacks:
63 * - task stack
64 * - softirq stack
65 * - hardirq stack
66 + * - SYSENTER stack
67 */
68 for (regs = NULL; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
69 const char *stack_name;
70
71 - /*
72 - * If we overflowed the task stack into a guard page, jump back
73 - * to the bottom of the usable stack.
74 - */
75 - if (task_stack_page(task) - (void *)stack < PAGE_SIZE)
76 - stack = task_stack_page(task);
77 -
78 - if (get_stack_info(stack, task, &stack_info, &visit_mask))
79 - break;
80 + if (get_stack_info(stack, task, &stack_info, &visit_mask)) {
81 + /*
82 + * We weren't on a valid stack. It's possible that
83 + * we overflowed a valid stack into a guard page.
84 + * See if the next page up is valid so that we can
85 + * generate some kind of backtrace if this happens.
86 + */
87 + stack = (unsigned long *)PAGE_ALIGN((unsigned long)stack);
88 + if (get_stack_info(stack, task, &stack_info, &visit_mask))
89 + break;
90 + }
91
92 stack_name = stack_type_name(stack_info.type);
93 if (stack_name)
94 --
95 2.14.2
96