| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- From 0e6d8e0cd5b1439d97f56445aef57d8839580b33 Mon Sep 17 00:00:00 2001
- From: Andy Lutomirski <[email protected]>
- Date: Mon, 4 Dec 2017 15:07:45 +0100
- Subject: [PATCH 198/242] x86/mm/pti: Share cpu_entry_area with user space page
- tables
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- Share the cpu entry area so the user space and kernel space page tables
- have the same P4D page.
- Signed-off-by: Andy Lutomirski <[email protected]>
- Signed-off-by: Thomas Gleixner <[email protected]>
- Cc: Boris Ostrovsky <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Brian Gerst <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: David Laight <[email protected]>
- Cc: Denys Vlasenko <[email protected]>
- Cc: Eduardo Valentin <[email protected]>
- Cc: Greg KH <[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: Will Deacon <[email protected]>
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Signed-off-by: Ingo Molnar <[email protected]>
- (cherry picked from commit f7cfbee91559ca7e3e961a00ffac921208a115ad)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit 6e8142de3a6e84a82a421b66a74ba37976912282)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/x86/mm/pti.c | 25 +++++++++++++++++++++++++
- 1 file changed, 25 insertions(+)
- diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
- index d58bcee470fc..59290356f19f 100644
- --- a/arch/x86/mm/pti.c
- +++ b/arch/x86/mm/pti.c
- @@ -264,6 +264,29 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
- }
- }
-
- +/*
- + * Clone a single p4d (i.e. a top-level entry on 4-level systems and a
- + * next-level entry on 5-level systems.
- + */
- +static void __init pti_clone_p4d(unsigned long addr)
- +{
- + p4d_t *kernel_p4d, *user_p4d;
- + pgd_t *kernel_pgd;
- +
- + user_p4d = pti_user_pagetable_walk_p4d(addr);
- + kernel_pgd = pgd_offset_k(addr);
- + kernel_p4d = p4d_offset(kernel_pgd, addr);
- + *user_p4d = *kernel_p4d;
- +}
- +
- +/*
- + * Clone the CPU_ENTRY_AREA into the user space visible page table.
- + */
- +static void __init pti_clone_user_shared(void)
- +{
- + pti_clone_p4d(CPU_ENTRY_AREA_BASE);
- +}
- +
- /*
- * Initialize kernel page table isolation
- */
- @@ -273,4 +296,6 @@ void __init pti_init(void)
- return;
-
- pr_info("enabled\n");
- +
- + pti_clone_user_shared();
- }
- --
- 2.14.2
|