]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0165-x86-mm-dump_pagetables-Make-the-address-hints-correc.patch
add objtool build fix
[pve-kernel.git] / patches / kernel / 0165-x86-mm-dump_pagetables-Make-the-address-hints-correc.patch
CommitLineData
321d628a
FG
1From e16f646082d458ec595304dbc2e6906fdc417495 Mon Sep 17 00:00:00 2001
2From: Thomas Gleixner <tglx@linutronix.de>
3Date: Wed, 20 Dec 2017 18:07:42 +0100
b378f209 4Subject: [PATCH 165/233] x86/mm/dump_pagetables: Make the address hints
321d628a
FG
5 correct and readable
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10CVE-2017-5754
11
12The address hints are a trainwreck. The array entry numbers have to kept
13magically in sync with the actual hints, which is doomed as some of the
14array members are initialized at runtime via the entry numbers.
15
16Designated initializers have been around before this code was
17implemented....
18
19Use the entry numbers to populate the address hints array and add the
20missing bits and pieces. Split 32 and 64 bit for readability sake.
21
22Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
23Cc: Andy Lutomirski <luto@kernel.org>
24Cc: Borislav Petkov <bp@alien8.de>
25Cc: Dave Hansen <dave.hansen@linux.intel.com>
26Cc: H. Peter Anvin <hpa@zytor.com>
27Cc: Josh Poimboeuf <jpoimboe@redhat.com>
28Cc: Juergen Gross <jgross@suse.com>
29Cc: Linus Torvalds <torvalds@linux-foundation.org>
30Cc: Peter Zijlstra <peterz@infradead.org>
31Cc: linux-kernel@vger.kernel.org
32Signed-off-by: Ingo Molnar <mingo@kernel.org>
33(cherry picked from commit 146122e24bdf208015d629babba673e28d090709)
34Signed-off-by: Andy Whitcroft <apw@canonical.com>
35Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
36(cherry picked from commit 7f4d9163531183fbaa0df1d1b1ceecbade4e58dc)
37Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
38---
39 arch/x86/mm/dump_pagetables.c | 90 +++++++++++++++++++++++++------------------
40 1 file changed, 53 insertions(+), 37 deletions(-)
41
42diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
43index 91aa41c5e0dd..318a7c30e87e 100644
44--- a/arch/x86/mm/dump_pagetables.c
45+++ b/arch/x86/mm/dump_pagetables.c
46@@ -44,10 +44,12 @@ struct addr_marker {
47 unsigned long max_lines;
48 };
49
50-/* indices for address_markers; keep sync'd w/ address_markers below */
51+/* Address space markers hints */
52+
53+#ifdef CONFIG_X86_64
54+
55 enum address_markers_idx {
56 USER_SPACE_NR = 0,
57-#ifdef CONFIG_X86_64
58 KERNEL_SPACE_NR,
59 LOW_KERNEL_NR,
60 VMALLOC_START_NR,
61@@ -56,56 +58,70 @@ enum address_markers_idx {
62 KASAN_SHADOW_START_NR,
63 KASAN_SHADOW_END_NR,
64 #endif
65-# ifdef CONFIG_X86_ESPFIX64
66+#ifdef CONFIG_X86_ESPFIX64
67 ESPFIX_START_NR,
68-# endif
69+#endif
70+#ifdef CONFIG_EFI
71+ EFI_END_NR,
72+#endif
73 HIGH_KERNEL_NR,
74 MODULES_VADDR_NR,
75 MODULES_END_NR,
76-#else
77+ FIXADDR_START_NR,
78+ END_OF_SPACE_NR,
79+};
80+
81+static struct addr_marker address_markers[] = {
82+ [USER_SPACE_NR] = { 0, "User Space" },
83+ [KERNEL_SPACE_NR] = { (1UL << 63), "Kernel Space" },
84+ [LOW_KERNEL_NR] = { 0UL, "Low Kernel Mapping" },
85+ [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
86+ [VMEMMAP_START_NR] = { 0UL, "Vmemmap" },
87+#ifdef CONFIG_KASAN
88+ [KASAN_SHADOW_START_NR] = { KASAN_SHADOW_START, "KASAN shadow" },
89+ [KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" },
90+#endif
91+#ifdef CONFIG_X86_ESPFIX64
92+ [ESPFIX_START_NR] = { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
93+#endif
94+#ifdef CONFIG_EFI
95+ [EFI_END_NR] = { EFI_VA_END, "EFI Runtime Services" },
96+#endif
97+ [HIGH_KERNEL_NR] = { __START_KERNEL_map, "High Kernel Mapping" },
98+ [MODULES_VADDR_NR] = { MODULES_VADDR, "Modules" },
99+ [MODULES_END_NR] = { MODULES_END, "End Modules" },
100+ [FIXADDR_START_NR] = { FIXADDR_START, "Fixmap Area" },
101+ [END_OF_SPACE_NR] = { -1, NULL }
102+};
103+
104+#else /* CONFIG_X86_64 */
105+
106+enum address_markers_idx {
107+ USER_SPACE_NR = 0,
108 KERNEL_SPACE_NR,
109 VMALLOC_START_NR,
110 VMALLOC_END_NR,
111-# ifdef CONFIG_HIGHMEM
112+#ifdef CONFIG_HIGHMEM
113 PKMAP_BASE_NR,
114-# endif
115- FIXADDR_START_NR,
116 #endif
117+ FIXADDR_START_NR,
118+ END_OF_SPACE_NR,
119 };
120
121-/* Address space markers hints */
122 static struct addr_marker address_markers[] = {
123- { 0, "User Space" },
124-#ifdef CONFIG_X86_64
125- { 0x8000000000000000UL, "Kernel Space" },
126- { 0/* PAGE_OFFSET */, "Low Kernel Mapping" },
127- { 0/* VMALLOC_START */, "vmalloc() Area" },
128- { 0/* VMEMMAP_START */, "Vmemmap" },
129-#ifdef CONFIG_KASAN
130- { KASAN_SHADOW_START, "KASAN shadow" },
131- { KASAN_SHADOW_END, "KASAN shadow end" },
132+ [USER_SPACE_NR] = { 0, "User Space" },
133+ [KERNEL_SPACE_NR] = { PAGE_OFFSET, "Kernel Mapping" },
134+ [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
135+ [VMALLOC_END_NR] = { 0UL, "vmalloc() End" },
136+#ifdef CONFIG_HIGHMEM
137+ [PKMAP_BASE_NR] = { 0UL, "Persistent kmap() Area" },
138 #endif
139-# ifdef CONFIG_X86_ESPFIX64
140- { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
141-# endif
142-# ifdef CONFIG_EFI
143- { EFI_VA_END, "EFI Runtime Services" },
144-# endif
145- { __START_KERNEL_map, "High Kernel Mapping" },
146- { MODULES_VADDR, "Modules" },
147- { MODULES_END, "End Modules" },
148-#else
149- { PAGE_OFFSET, "Kernel Mapping" },
150- { 0/* VMALLOC_START */, "vmalloc() Area" },
151- { 0/*VMALLOC_END*/, "vmalloc() End" },
152-# ifdef CONFIG_HIGHMEM
153- { 0/*PKMAP_BASE*/, "Persistent kmap() Area" },
154-# endif
155- { 0/*FIXADDR_START*/, "Fixmap Area" },
156-#endif
157- { -1, NULL } /* End of list */
158+ [FIXADDR_START_NR] = { 0UL, "Fixmap area" },
159+ [END_OF_SPACE_NR] = { -1, NULL }
160 };
161
162+#endif /* !CONFIG_X86_64 */
163+
164 /* Multipliers for offsets within the PTEs */
165 #define PTE_LEVEL_MULT (PAGE_SIZE)
166 #define PMD_LEVEL_MULT (PTRS_PER_PTE * PTE_LEVEL_MULT)
167--
1682.14.2
169