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