0094-x86-entry-64-Use-pop-instead-of-movq-in-syscall_retu.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Thu, 2 Nov 2017 00:59:03 -0700
  4. Subject: [PATCH] x86/entry/64: Use pop instead of movq in
  5. syscall_return_via_sysret
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. Saves 64 bytes.
  11. Signed-off-by: Andy Lutomirski <[email protected]>
  12. Reviewed-by: Borislav Petkov <[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/6609b7f74ab31c36604ad746e019ea8495aec76c.1509609304.git.luto@kernel.org
  20. Signed-off-by: Ingo Molnar <[email protected]>
  21. (cherry picked from commit 4fbb39108f972437c44e5ffa781b56635d496826)
  22. Signed-off-by: Andy Whitcroft <[email protected]>
  23. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  24. (cherry picked from commit 1e9a9d5ef9f65eeb26eb8f0974dd3e693894baf1)
  25. Signed-off-by: Fabian Grünbichler <[email protected]>
  26. ---
  27. arch/x86/entry/entry_64.S | 14 +++++++++++---
  28. 1 file changed, 11 insertions(+), 3 deletions(-)
  29. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  30. index 6995f7e08aa1..33a416c7df2d 100644
  31. --- a/arch/x86/entry/entry_64.S
  32. +++ b/arch/x86/entry/entry_64.S
  33. @@ -315,10 +315,18 @@ return_from_SYSCALL_64:
  34. */
  35. syscall_return_via_sysret:
  36. /* rcx and r11 are already restored (see code above) */
  37. - RESTORE_EXTRA_REGS
  38. - RESTORE_C_REGS_EXCEPT_RCX_R11
  39. - movq RSP(%rsp), %rsp
  40. UNWIND_HINT_EMPTY
  41. + POP_EXTRA_REGS
  42. + popq %rsi /* skip r11 */
  43. + popq %r10
  44. + popq %r9
  45. + popq %r8
  46. + popq %rax
  47. + popq %rsi /* skip rcx */
  48. + popq %rdx
  49. + popq %rsi
  50. + popq %rdi
  51. + movq RSP-ORIG_RAX(%rsp), %rsp
  52. USERGS_SYSRET64
  53. END(entry_SYSCALL_64)
  54. --
  55. 2.14.2