0092-x86-entry-64-Merge-the-fast-and-slow-SYSRET-paths.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From c48697564de6da427f1e97a38192f4d456223942 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Thu, 2 Nov 2017 00:59:04 -0700
  4. Subject: [PATCH 092/231] x86/entry/64: Merge the fast and slow SYSRET paths
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. They did almost the same thing. Remove a bunch of pointless
  10. instructions (mostly hidden in macros) and reduce cognitive load by
  11. merging them.
  12. Signed-off-by: Andy Lutomirski <[email protected]>
  13. Cc: Borislav Petkov <[email protected]>
  14. Cc: Brian Gerst <[email protected]>
  15. Cc: Dave Hansen <[email protected]>
  16. Cc: Linus Torvalds <[email protected]>
  17. Cc: Peter Zijlstra <[email protected]>
  18. Cc: Thomas Gleixner <[email protected]>
  19. Link: http://lkml.kernel.org/r/1204e20233fcab9130a1ba80b3b1879b5db3fc1f.1509609304.git.luto@kernel.org
  20. Signed-off-by: Ingo Molnar <[email protected]>
  21. (cherry picked from commit a512210643da8082cb44181dba8b18e752bd68f0)
  22. Signed-off-by: Andy Whitcroft <[email protected]>
  23. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  24. (cherry picked from commit 7c4575d8bb2d01960ba9b9840fa22460e0179eca)
  25. Signed-off-by: Fabian Grünbichler <[email protected]>
  26. ---
  27. arch/x86/entry/entry_64.S | 6 +++---
  28. 1 file changed, 3 insertions(+), 3 deletions(-)
  29. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  30. index 33a416c7df2d..87be1cd1fa88 100644
  31. --- a/arch/x86/entry/entry_64.S
  32. +++ b/arch/x86/entry/entry_64.S
  33. @@ -220,10 +220,9 @@ entry_SYSCALL_64_fastpath:
  34. TRACE_IRQS_ON /* user mode is traced as IRQs on */
  35. movq RIP(%rsp), %rcx
  36. movq EFLAGS(%rsp), %r11
  37. - RESTORE_C_REGS_EXCEPT_RCX_R11
  38. - movq RSP(%rsp), %rsp
  39. + addq $6*8, %rsp /* skip extra regs -- they were preserved */
  40. UNWIND_HINT_EMPTY
  41. - USERGS_SYSRET64
  42. + jmp .Lpop_c_regs_except_rcx_r11_and_sysret
  43. 1:
  44. /*
  45. @@ -317,6 +316,7 @@ syscall_return_via_sysret:
  46. /* rcx and r11 are already restored (see code above) */
  47. UNWIND_HINT_EMPTY
  48. POP_EXTRA_REGS
  49. +.Lpop_c_regs_except_rcx_r11_and_sysret:
  50. popq %rsi /* skip r11 */
  51. popq %r10
  52. popq %r9
  53. --
  54. 2.14.2