]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0198-x86-mm-pti-Share-cpu_entry_area-with-user-space-page.patch
build: reformat existing patches
[pve-kernel.git] / patches / kernel / 0198-x86-mm-pti-Share-cpu_entry_area-with-user-space-page.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Andy Lutomirski <luto@kernel.org>
3 Date: Mon, 4 Dec 2017 15:07:45 +0100
4 Subject: [PATCH] x86/mm/pti: Share cpu_entry_area with user space page tables
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 Share the cpu entry area so the user space and kernel space page tables
12 have the same P4D page.
13
14 Signed-off-by: Andy Lutomirski <luto@kernel.org>
15 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16 Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
17 Cc: Borislav Petkov <bp@alien8.de>
18 Cc: Brian Gerst <brgerst@gmail.com>
19 Cc: Dave Hansen <dave.hansen@linux.intel.com>
20 Cc: David Laight <David.Laight@aculab.com>
21 Cc: Denys Vlasenko <dvlasenk@redhat.com>
22 Cc: Eduardo Valentin <eduval@amazon.com>
23 Cc: Greg KH <gregkh@linuxfoundation.org>
24 Cc: H. Peter Anvin <hpa@zytor.com>
25 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
26 Cc: Juergen Gross <jgross@suse.com>
27 Cc: Linus Torvalds <torvalds@linux-foundation.org>
28 Cc: Peter Zijlstra <peterz@infradead.org>
29 Cc: Will Deacon <will.deacon@arm.com>
30 Cc: aliguori@amazon.com
31 Cc: daniel.gruss@iaik.tugraz.at
32 Cc: hughd@google.com
33 Cc: keescook@google.com
34 Signed-off-by: Ingo Molnar <mingo@kernel.org>
35 (cherry picked from commit f7cfbee91559ca7e3e961a00ffac921208a115ad)
36 Signed-off-by: Andy Whitcroft <apw@canonical.com>
37 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
38 (cherry picked from commit 6e8142de3a6e84a82a421b66a74ba37976912282)
39 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
40 ---
41 arch/x86/mm/pti.c | 25 +++++++++++++++++++++++++
42 1 file changed, 25 insertions(+)
43
44 diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
45 index d58bcee470fc..59290356f19f 100644
46 --- a/arch/x86/mm/pti.c
47 +++ b/arch/x86/mm/pti.c
48 @@ -264,6 +264,29 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
49 }
50 }
51
52 +/*
53 + * Clone a single p4d (i.e. a top-level entry on 4-level systems and a
54 + * next-level entry on 5-level systems.
55 + */
56 +static void __init pti_clone_p4d(unsigned long addr)
57 +{
58 + p4d_t *kernel_p4d, *user_p4d;
59 + pgd_t *kernel_pgd;
60 +
61 + user_p4d = pti_user_pagetable_walk_p4d(addr);
62 + kernel_pgd = pgd_offset_k(addr);
63 + kernel_p4d = p4d_offset(kernel_pgd, addr);
64 + *user_p4d = *kernel_p4d;
65 +}
66 +
67 +/*
68 + * Clone the CPU_ENTRY_AREA into the user space visible page table.
69 + */
70 +static void __init pti_clone_user_shared(void)
71 +{
72 + pti_clone_p4d(CPU_ENTRY_AREA_BASE);
73 +}
74 +
75 /*
76 * Initialize kernel page table isolation
77 */
78 @@ -273,4 +296,6 @@ void __init pti_init(void)
79 return;
80
81 pr_info("enabled\n");
82 +
83 + pti_clone_user_shared();
84 }
85 --
86 2.14.2
87