]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0200-x86-mm-pti-Share-entry-text-PMD.patch
KPTI: add follow-up fixes
[pve-kernel.git] / patches / kernel / 0200-x86-mm-pti-Share-entry-text-PMD.patch
CommitLineData
321d628a
FG
1From 9b8667a59df870d8f965d6681cb18843302c8510 Mon Sep 17 00:00:00 2001
2From: Thomas Gleixner <tglx@linutronix.de>
3Date: Mon, 4 Dec 2017 15:07:47 +0100
e4cdf2a5 4Subject: [PATCH 200/241] x86/mm/pti: Share entry text PMD
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11Share the entry text PMD of the kernel mapping with the user space
12mapping. If large pages are enabled this is a single PMD entry and at the
13point where it is copied into the user page table the RW bit has not been
14cleared yet. Clear it right away so the user space visible map becomes RX.
15
16Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
17Cc: Andy Lutomirski <luto@kernel.org>
18Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
19Cc: Borislav Petkov <bp@alien8.de>
20Cc: Brian Gerst <brgerst@gmail.com>
21Cc: Dave Hansen <dave.hansen@linux.intel.com>
22Cc: David Laight <David.Laight@aculab.com>
23Cc: Denys Vlasenko <dvlasenk@redhat.com>
24Cc: Eduardo Valentin <eduval@amazon.com>
25Cc: Greg KH <gregkh@linuxfoundation.org>
26Cc: H. Peter Anvin <hpa@zytor.com>
27Cc: Josh Poimboeuf <jpoimboe@redhat.com>
28Cc: Juergen Gross <jgross@suse.com>
29Cc: Linus Torvalds <torvalds@linux-foundation.org>
30Cc: Peter Zijlstra <peterz@infradead.org>
31Cc: Will Deacon <will.deacon@arm.com>
32Cc: aliguori@amazon.com
33Cc: daniel.gruss@iaik.tugraz.at
34Cc: hughd@google.com
35Cc: keescook@google.com
36Signed-off-by: Ingo Molnar <mingo@kernel.org>
37(cherry picked from commit 6dc72c3cbca0580642808d677181cad4c6433893)
38Signed-off-by: Andy Whitcroft <apw@canonical.com>
39Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
40(cherry picked from commit ee98d7446b4a7c12a57a38b1a5f51e3df0ac2cf3)
41Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
42---
43 arch/x86/mm/pti.c | 10 ++++++++++
44 1 file changed, 10 insertions(+)
45
46diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
47index 59290356f19f..0e78797650a7 100644
48--- a/arch/x86/mm/pti.c
49+++ b/arch/x86/mm/pti.c
50@@ -287,6 +287,15 @@ static void __init pti_clone_user_shared(void)
51 pti_clone_p4d(CPU_ENTRY_AREA_BASE);
52 }
53
54+/*
55+ * Clone the populated PMDs of the entry and irqentry text and force it RO.
56+ */
57+static void __init pti_clone_entry_text(void)
58+{
59+ pti_clone_pmds((unsigned long) __entry_text_start,
60+ (unsigned long) __irqentry_text_end, _PAGE_RW);
61+}
62+
63 /*
64 * Initialize kernel page table isolation
65 */
66@@ -298,4 +307,5 @@ void __init pti_init(void)
67 pr_info("enabled\n");
68
69 pti_clone_user_shared();
70+ pti_clone_entry_text();
71 }
72--
732.14.2
74