| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- From 3bc42412073e1c559266e2b07bc1fbce154d92dc Mon Sep 17 00:00:00 2001
- From: Dave Hansen <[email protected]>
- Date: Mon, 4 Dec 2017 15:07:40 +0100
- Subject: [PATCH 195/242] x86/mm/pti: Populate user PGD
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- In clone_pgd_range() copy the init user PGDs which cover the kernel half of
- the address space, so a process has all the required kernel mappings
- visible.
- [ tglx: Split out from the big kaiser dump and folded Andys simplification ]
- Signed-off-by: Dave Hansen <[email protected]>
- Signed-off-by: Thomas Gleixner <[email protected]>
- Reviewed-by: Borislav Petkov <[email protected]>
- Cc: Andy Lutomirski <[email protected]>
- Cc: Boris Ostrovsky <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Brian Gerst <[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 fc2fbc8512ed08d1de7720936fd7d2e4ce02c3a2)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit 26c08c52162e1079cbb3e9ce8e1346a100ea7ccc)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/x86/include/asm/pgtable.h | 9 ++++++++-
- 1 file changed, 8 insertions(+), 1 deletion(-)
- diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
- index 3ef8415b2358..25604b8a251a 100644
- --- a/arch/x86/include/asm/pgtable.h
- +++ b/arch/x86/include/asm/pgtable.h
- @@ -1104,7 +1104,14 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
- */
- static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
- {
- - memcpy(dst, src, count * sizeof(pgd_t));
- + memcpy(dst, src, count * sizeof(pgd_t));
- +#ifdef CONFIG_PAGE_TABLE_ISOLATION
- + if (!static_cpu_has(X86_FEATURE_PTI))
- + return;
- + /* Clone the user space pgd as well */
- + memcpy(kernel_to_user_pgdp(dst), kernel_to_user_pgdp(src),
- + count * sizeof(pgd_t));
- +#endif
- }
-
- #define PTE_SHIFT ilog2(PTRS_PER_PTE)
- --
- 2.14.2
|