0086-x86-entry-64-Remove-the-restore_c_regs_and_iret-labe.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. From befef5ef70f959cd51694298c4370557e5d846cf Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Thu, 2 Nov 2017 00:58:58 -0700
  4. Subject: [PATCH 086/242] x86/entry/64: Remove the restore_c_regs_and_iret
  5. label
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. The only user was the 64-bit opportunistic SYSRET failure path, and
  11. that path didn't really need it. This change makes the
  12. opportunistic SYSRET code a bit more straightforward and gets rid of
  13. the label.
  14. Signed-off-by: Andy Lutomirski <[email protected]>
  15. Reviewed-by: Borislav Petkov <[email protected]>
  16. Cc: Borislav Petkov <[email protected]>
  17. Cc: Brian Gerst <[email protected]>
  18. Cc: Dave Hansen <[email protected]>
  19. Cc: Linus Torvalds <[email protected]>
  20. Cc: Peter Zijlstra <[email protected]>
  21. Cc: Thomas Gleixner <[email protected]>
  22. Link: http://lkml.kernel.org/r/be3006a7ad3326e3458cf1cc55d416252cbe1986.1509609304.git.luto@kernel.org
  23. Signed-off-by: Ingo Molnar <[email protected]>
  24. (cherry picked from commit 9da78ba6b47b46428cfdfc0851511ab29c869798)
  25. Signed-off-by: Andy Whitcroft <[email protected]>
  26. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  27. (cherry picked from commit 629c8b858cbe72e88e7f44a8f10e1b434ab80721)
  28. Signed-off-by: Fabian Grünbichler <[email protected]>
  29. ---
  30. arch/x86/entry/entry_64.S | 5 ++---
  31. 1 file changed, 2 insertions(+), 3 deletions(-)
  32. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  33. index 34adfe0221d2..fac354ddf056 100644
  34. --- a/arch/x86/entry/entry_64.S
  35. +++ b/arch/x86/entry/entry_64.S
  36. @@ -245,7 +245,6 @@ entry_SYSCALL64_slow_path:
  37. call do_syscall_64 /* returns with IRQs disabled */
  38. return_from_SYSCALL_64:
  39. - RESTORE_EXTRA_REGS
  40. TRACE_IRQS_IRETQ /* we're about to change IF */
  41. /*
  42. @@ -314,6 +313,7 @@ return_from_SYSCALL_64:
  43. */
  44. syscall_return_via_sysret:
  45. /* rcx and r11 are already restored (see code above) */
  46. + RESTORE_EXTRA_REGS
  47. RESTORE_C_REGS_EXCEPT_RCX_R11
  48. movq RSP(%rsp), %rsp
  49. UNWIND_HINT_EMPTY
  50. @@ -321,7 +321,7 @@ syscall_return_via_sysret:
  51. opportunistic_sysret_failed:
  52. SWAPGS
  53. - jmp restore_c_regs_and_iret
  54. + jmp restore_regs_and_iret
  55. END(entry_SYSCALL_64)
  56. ENTRY(stub_ptregs_64)
  57. @@ -638,7 +638,6 @@ retint_kernel:
  58. */
  59. GLOBAL(restore_regs_and_iret)
  60. RESTORE_EXTRA_REGS
  61. -restore_c_regs_and_iret:
  62. RESTORE_C_REGS
  63. REMOVE_PT_GPREGS_FROM_STACK 8
  64. INTERRUPT_RETURN
  65. --
  66. 2.14.2