0201-x86-mm-pti-Map-ESPFIX-into-user-space.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 9378cf5830b41fc4659335da883d2a1d52fe0661 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Fri, 15 Dec 2017 22:08:18 +0100
  4. Subject: [PATCH 201/242] x86/mm/pti: Map ESPFIX into user space
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. Map the ESPFIX pages into user space when PTI is enabled.
  10. Signed-off-by: Andy Lutomirski <[email protected]>
  11. Signed-off-by: Thomas Gleixner <[email protected]>
  12. Cc: Borislav Petkov <[email protected]>
  13. Cc: Brian Gerst <[email protected]>
  14. Cc: Dave Hansen <[email protected]>
  15. Cc: David Laight <[email protected]>
  16. Cc: H. Peter Anvin <[email protected]>
  17. Cc: Josh Poimboeuf <[email protected]>
  18. Cc: Juergen Gross <[email protected]>
  19. Cc: Kees Cook <[email protected]>
  20. Cc: Linus Torvalds <[email protected]>
  21. Cc: Peter Zijlstra <[email protected]>
  22. Signed-off-by: Ingo Molnar <[email protected]>
  23. (cherry picked from commit 4b6bbe95b87966ba08999574db65c93c5e925a36)
  24. Signed-off-by: Andy Whitcroft <[email protected]>
  25. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  26. (cherry picked from commit f5103cc3035ae6d1816404696ee2eb06d53b6709)
  27. Signed-off-by: Fabian Grünbichler <[email protected]>
  28. ---
  29. arch/x86/mm/pti.c | 11 +++++++++++
  30. 1 file changed, 11 insertions(+)
  31. diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
  32. index 0e78797650a7..b1c38ef9fbbb 100644
  33. --- a/arch/x86/mm/pti.c
  34. +++ b/arch/x86/mm/pti.c
  35. @@ -287,6 +287,16 @@ static void __init pti_clone_user_shared(void)
  36. pti_clone_p4d(CPU_ENTRY_AREA_BASE);
  37. }
  38. +/*
  39. + * Clone the ESPFIX P4D into the user space visinble page table
  40. + */
  41. +static void __init pti_setup_espfix64(void)
  42. +{
  43. +#ifdef CONFIG_X86_ESPFIX64
  44. + pti_clone_p4d(ESPFIX_BASE_ADDR);
  45. +#endif
  46. +}
  47. +
  48. /*
  49. * Clone the populated PMDs of the entry and irqentry text and force it RO.
  50. */
  51. @@ -308,4 +318,5 @@ void __init pti_init(void)
  52. pti_clone_user_shared();
  53. pti_clone_entry_text();
  54. + pti_setup_espfix64();
  55. }
  56. --
  57. 2.14.2