]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0195-x86-mm-pti-Populate-user-PGD.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0195-x86-mm-pti-Populate-user-PGD.patch
CommitLineData
321d628a
FG
1From 3bc42412073e1c559266e2b07bc1fbce154d92dc Mon Sep 17 00:00:00 2001
2From: Dave Hansen <dave.hansen@linux.intel.com>
3Date: Mon, 4 Dec 2017 15:07:40 +0100
e4cdf2a5 4Subject: [PATCH 195/241] x86/mm/pti: Populate user PGD
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11In clone_pgd_range() copy the init user PGDs which cover the kernel half of
12the address space, so a process has all the required kernel mappings
13visible.
14
15[ tglx: Split out from the big kaiser dump and folded Andys simplification ]
16
17Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
18Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
19Reviewed-by: Borislav Petkov <bp@suse.de>
20Cc: Andy Lutomirski <luto@kernel.org>
21Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
22Cc: Borislav Petkov <bp@alien8.de>
23Cc: Brian Gerst <brgerst@gmail.com>
24Cc: David Laight <David.Laight@aculab.com>
25Cc: Denys Vlasenko <dvlasenk@redhat.com>
26Cc: Eduardo Valentin <eduval@amazon.com>
27Cc: Greg KH <gregkh@linuxfoundation.org>
28Cc: H. Peter Anvin <hpa@zytor.com>
29Cc: Josh Poimboeuf <jpoimboe@redhat.com>
30Cc: Juergen Gross <jgross@suse.com>
31Cc: Linus Torvalds <torvalds@linux-foundation.org>
32Cc: Peter Zijlstra <peterz@infradead.org>
33Cc: Will Deacon <will.deacon@arm.com>
34Cc: aliguori@amazon.com
35Cc: daniel.gruss@iaik.tugraz.at
36Cc: hughd@google.com
37Cc: keescook@google.com
38Signed-off-by: Ingo Molnar <mingo@kernel.org>
39(cherry picked from commit fc2fbc8512ed08d1de7720936fd7d2e4ce02c3a2)
40Signed-off-by: Andy Whitcroft <apw@canonical.com>
41Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
42(cherry picked from commit 26c08c52162e1079cbb3e9ce8e1346a100ea7ccc)
43Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
44---
45 arch/x86/include/asm/pgtable.h | 9 ++++++++-
46 1 file changed, 8 insertions(+), 1 deletion(-)
47
48diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
49index 3ef8415b2358..25604b8a251a 100644
50--- a/arch/x86/include/asm/pgtable.h
51+++ b/arch/x86/include/asm/pgtable.h
52@@ -1104,7 +1104,14 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
53 */
54 static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
55 {
56- memcpy(dst, src, count * sizeof(pgd_t));
57+ memcpy(dst, src, count * sizeof(pgd_t));
58+#ifdef CONFIG_PAGE_TABLE_ISOLATION
59+ if (!static_cpu_has(X86_FEATURE_PTI))
60+ return;
61+ /* Clone the user space pgd as well */
62+ memcpy(kernel_to_user_pgdp(dst), kernel_to_user_pgdp(src),
63+ count * sizeof(pgd_t));
64+#endif
65 }
66
67 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
68--
692.14.2
70