| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- From e16f646082d458ec595304dbc2e6906fdc417495 Mon Sep 17 00:00:00 2001
- From: Thomas Gleixner <[email protected]>
- Date: Wed, 20 Dec 2017 18:07:42 +0100
- Subject: [PATCH 165/242] x86/mm/dump_pagetables: Make the address hints
- correct and readable
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- The address hints are a trainwreck. The array entry numbers have to kept
- magically in sync with the actual hints, which is doomed as some of the
- array members are initialized at runtime via the entry numbers.
- Designated initializers have been around before this code was
- implemented....
- Use the entry numbers to populate the address hints array and add the
- missing bits and pieces. Split 32 and 64 bit for readability sake.
- Signed-off-by: Thomas Gleixner <[email protected]>
- Cc: Andy Lutomirski <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Dave Hansen <[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: [email protected]
- Signed-off-by: Ingo Molnar <[email protected]>
- (cherry picked from commit 146122e24bdf208015d629babba673e28d090709)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit 7f4d9163531183fbaa0df1d1b1ceecbade4e58dc)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/x86/mm/dump_pagetables.c | 90 +++++++++++++++++++++++++------------------
- 1 file changed, 53 insertions(+), 37 deletions(-)
- diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
- index 91aa41c5e0dd..318a7c30e87e 100644
- --- a/arch/x86/mm/dump_pagetables.c
- +++ b/arch/x86/mm/dump_pagetables.c
- @@ -44,10 +44,12 @@ struct addr_marker {
- unsigned long max_lines;
- };
-
- -/* indices for address_markers; keep sync'd w/ address_markers below */
- +/* Address space markers hints */
- +
- +#ifdef CONFIG_X86_64
- +
- enum address_markers_idx {
- USER_SPACE_NR = 0,
- -#ifdef CONFIG_X86_64
- KERNEL_SPACE_NR,
- LOW_KERNEL_NR,
- VMALLOC_START_NR,
- @@ -56,56 +58,70 @@ enum address_markers_idx {
- KASAN_SHADOW_START_NR,
- KASAN_SHADOW_END_NR,
- #endif
- -# ifdef CONFIG_X86_ESPFIX64
- +#ifdef CONFIG_X86_ESPFIX64
- ESPFIX_START_NR,
- -# endif
- +#endif
- +#ifdef CONFIG_EFI
- + EFI_END_NR,
- +#endif
- HIGH_KERNEL_NR,
- MODULES_VADDR_NR,
- MODULES_END_NR,
- -#else
- + FIXADDR_START_NR,
- + END_OF_SPACE_NR,
- +};
- +
- +static struct addr_marker address_markers[] = {
- + [USER_SPACE_NR] = { 0, "User Space" },
- + [KERNEL_SPACE_NR] = { (1UL << 63), "Kernel Space" },
- + [LOW_KERNEL_NR] = { 0UL, "Low Kernel Mapping" },
- + [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
- + [VMEMMAP_START_NR] = { 0UL, "Vmemmap" },
- +#ifdef CONFIG_KASAN
- + [KASAN_SHADOW_START_NR] = { KASAN_SHADOW_START, "KASAN shadow" },
- + [KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" },
- +#endif
- +#ifdef CONFIG_X86_ESPFIX64
- + [ESPFIX_START_NR] = { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
- +#endif
- +#ifdef CONFIG_EFI
- + [EFI_END_NR] = { EFI_VA_END, "EFI Runtime Services" },
- +#endif
- + [HIGH_KERNEL_NR] = { __START_KERNEL_map, "High Kernel Mapping" },
- + [MODULES_VADDR_NR] = { MODULES_VADDR, "Modules" },
- + [MODULES_END_NR] = { MODULES_END, "End Modules" },
- + [FIXADDR_START_NR] = { FIXADDR_START, "Fixmap Area" },
- + [END_OF_SPACE_NR] = { -1, NULL }
- +};
- +
- +#else /* CONFIG_X86_64 */
- +
- +enum address_markers_idx {
- + USER_SPACE_NR = 0,
- KERNEL_SPACE_NR,
- VMALLOC_START_NR,
- VMALLOC_END_NR,
- -# ifdef CONFIG_HIGHMEM
- +#ifdef CONFIG_HIGHMEM
- PKMAP_BASE_NR,
- -# endif
- - FIXADDR_START_NR,
- #endif
- + FIXADDR_START_NR,
- + END_OF_SPACE_NR,
- };
-
- -/* Address space markers hints */
- static struct addr_marker address_markers[] = {
- - { 0, "User Space" },
- -#ifdef CONFIG_X86_64
- - { 0x8000000000000000UL, "Kernel Space" },
- - { 0/* PAGE_OFFSET */, "Low Kernel Mapping" },
- - { 0/* VMALLOC_START */, "vmalloc() Area" },
- - { 0/* VMEMMAP_START */, "Vmemmap" },
- -#ifdef CONFIG_KASAN
- - { KASAN_SHADOW_START, "KASAN shadow" },
- - { KASAN_SHADOW_END, "KASAN shadow end" },
- + [USER_SPACE_NR] = { 0, "User Space" },
- + [KERNEL_SPACE_NR] = { PAGE_OFFSET, "Kernel Mapping" },
- + [VMALLOC_START_NR] = { 0UL, "vmalloc() Area" },
- + [VMALLOC_END_NR] = { 0UL, "vmalloc() End" },
- +#ifdef CONFIG_HIGHMEM
- + [PKMAP_BASE_NR] = { 0UL, "Persistent kmap() Area" },
- #endif
- -# ifdef CONFIG_X86_ESPFIX64
- - { ESPFIX_BASE_ADDR, "ESPfix Area", 16 },
- -# endif
- -# ifdef CONFIG_EFI
- - { EFI_VA_END, "EFI Runtime Services" },
- -# endif
- - { __START_KERNEL_map, "High Kernel Mapping" },
- - { MODULES_VADDR, "Modules" },
- - { MODULES_END, "End Modules" },
- -#else
- - { PAGE_OFFSET, "Kernel Mapping" },
- - { 0/* VMALLOC_START */, "vmalloc() Area" },
- - { 0/*VMALLOC_END*/, "vmalloc() End" },
- -# ifdef CONFIG_HIGHMEM
- - { 0/*PKMAP_BASE*/, "Persistent kmap() Area" },
- -# endif
- - { 0/*FIXADDR_START*/, "Fixmap Area" },
- -#endif
- - { -1, NULL } /* End of list */
- + [FIXADDR_START_NR] = { 0UL, "Fixmap area" },
- + [END_OF_SPACE_NR] = { -1, NULL }
- };
-
- +#endif /* !CONFIG_X86_64 */
- +
- /* Multipliers for offsets within the PTEs */
- #define PTE_LEVEL_MULT (PAGE_SIZE)
- #define PMD_LEVEL_MULT (PTRS_PER_PTE * PTE_LEVEL_MULT)
- --
- 2.14.2
|