0200-x86-mm-pti-Share-entry-text-PMD.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From 9b8667a59df870d8f965d6681cb18843302c8510 Mon Sep 17 00:00:00 2001
  2. From: Thomas Gleixner <[email protected]>
  3. Date: Mon, 4 Dec 2017 15:07:47 +0100
  4. Subject: [PATCH 200/242] x86/mm/pti: Share entry text PMD
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. Share the entry text PMD of the kernel mapping with the user space
  10. mapping. If large pages are enabled this is a single PMD entry and at the
  11. point where it is copied into the user page table the RW bit has not been
  12. cleared yet. Clear it right away so the user space visible map becomes RX.
  13. Signed-off-by: Thomas Gleixner <[email protected]>
  14. Cc: Andy Lutomirski <[email protected]>
  15. Cc: Boris Ostrovsky <[email protected]>
  16. Cc: Borislav Petkov <[email protected]>
  17. Cc: Brian Gerst <[email protected]>
  18. Cc: Dave Hansen <[email protected]>
  19. Cc: David Laight <[email protected]>
  20. Cc: Denys Vlasenko <[email protected]>
  21. Cc: Eduardo Valentin <[email protected]>
  22. Cc: Greg KH <[email protected]>
  23. Cc: H. Peter Anvin <[email protected]>
  24. Cc: Josh Poimboeuf <[email protected]>
  25. Cc: Juergen Gross <[email protected]>
  26. Cc: Linus Torvalds <[email protected]>
  27. Cc: Peter Zijlstra <[email protected]>
  28. Cc: Will Deacon <[email protected]>
  29. Cc: [email protected]
  30. Cc: [email protected]
  31. Cc: [email protected]
  32. Cc: [email protected]
  33. Signed-off-by: Ingo Molnar <[email protected]>
  34. (cherry picked from commit 6dc72c3cbca0580642808d677181cad4c6433893)
  35. Signed-off-by: Andy Whitcroft <[email protected]>
  36. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  37. (cherry picked from commit ee98d7446b4a7c12a57a38b1a5f51e3df0ac2cf3)
  38. Signed-off-by: Fabian Grünbichler <[email protected]>
  39. ---
  40. arch/x86/mm/pti.c | 10 ++++++++++
  41. 1 file changed, 10 insertions(+)
  42. diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
  43. index 59290356f19f..0e78797650a7 100644
  44. --- a/arch/x86/mm/pti.c
  45. +++ b/arch/x86/mm/pti.c
  46. @@ -287,6 +287,15 @@ static void __init pti_clone_user_shared(void)
  47. pti_clone_p4d(CPU_ENTRY_AREA_BASE);
  48. }
  49. +/*
  50. + * Clone the populated PMDs of the entry and irqentry text and force it RO.
  51. + */
  52. +static void __init pti_clone_entry_text(void)
  53. +{
  54. + pti_clone_pmds((unsigned long) __entry_text_start,
  55. + (unsigned long) __irqentry_text_end, _PAGE_RW);
  56. +}
  57. +
  58. /*
  59. * Initialize kernel page table isolation
  60. */
  61. @@ -298,4 +307,5 @@ void __init pti_init(void)
  62. pr_info("enabled\n");
  63. pti_clone_user_shared();
  64. + pti_clone_entry_text();
  65. }
  66. --
  67. 2.14.2