0019-x86-tboot-Unbreak-tboot-with-PTI-enabled.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Dave Hansen <[email protected]>
  3. Date: Sat, 6 Jan 2018 18:41:14 +0100
  4. Subject: [PATCH] x86/tboot: Unbreak tboot with PTI enabled
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. commit 262b6b30087246abf09d6275eb0c0dc421bcbe38 upstream.
  9. This is another case similar to what EFI does: create a new set of
  10. page tables, map some code at a low address, and jump to it. PTI
  11. mistakes this low address for userspace and mistakenly marks it
  12. non-executable in an effort to make it unusable for userspace.
  13. Undo the poison to allow execution.
  14. Fixes: 385ce0ea4c07 ("x86/mm/pti: Add Kconfig")
  15. Signed-off-by: Dave Hansen <[email protected]>
  16. Signed-off-by: Andrea Arcangeli <[email protected]>
  17. Signed-off-by: Thomas Gleixner <[email protected]>
  18. Cc: Alan Cox <[email protected]>
  19. Cc: Tim Chen <[email protected]>
  20. Cc: Jon Masters <[email protected]>
  21. Cc: Dave Hansen <[email protected]>
  22. Cc: Andi Kleen <[email protected]>
  23. Cc: Jeff Law <[email protected]>
  24. Cc: Paolo Bonzini <[email protected]>
  25. Cc: Linus Torvalds <[email protected]>
  26. Cc: Greg Kroah-Hartman <[email protected]>
  27. Cc: David" <[email protected]>
  28. Cc: Nick Clifton <[email protected]>
  29. Link: https://lkml.kernel.org/r/[email protected]
  30. Signed-off-by: Greg Kroah-Hartman <[email protected]>
  31. Signed-off-by: Fabian Grünbichler <[email protected]>
  32. ---
  33. arch/x86/kernel/tboot.c | 1 +
  34. 1 file changed, 1 insertion(+)
  35. diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
  36. index a2486f444073..8337730f0956 100644
  37. --- a/arch/x86/kernel/tboot.c
  38. +++ b/arch/x86/kernel/tboot.c
  39. @@ -127,6 +127,7 @@ static int map_tboot_page(unsigned long vaddr, unsigned long pfn,
  40. p4d = p4d_alloc(&tboot_mm, pgd, vaddr);
  41. if (!p4d)
  42. return -1;
  43. + pgd->pgd &= ~_PAGE_NX;
  44. pud = pud_alloc(&tboot_mm, p4d, vaddr);
  45. if (!pud)
  46. return -1;
  47. --
  48. 2.14.2