0093-x86-entry-64-Use-POP-instead-of-MOV-to-restore-regs-.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From c801c4e1ba695ba230e97f626abaeb0c16393b09 Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Thu, 2 Nov 2017 00:59:05 -0700
  4. Subject: [PATCH 093/241] x86/entry/64: Use POP instead of MOV to restore regs
  5. on NMI return
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. This gets rid of the last user of the old RESTORE_..._REGS infrastructure.
  11. Signed-off-by: Andy Lutomirski <[email protected]>
  12. Cc: Borislav Petkov <[email protected]>
  13. Cc: Brian Gerst <[email protected]>
  14. Cc: Dave Hansen <[email protected]>
  15. Cc: Linus Torvalds <[email protected]>
  16. Cc: Peter Zijlstra <[email protected]>
  17. Cc: Thomas Gleixner <[email protected]>
  18. Link: http://lkml.kernel.org/r/652a260f17a160789bc6a41d997f98249b73e2ab.1509609304.git.luto@kernel.org
  19. Signed-off-by: Ingo Molnar <[email protected]>
  20. (cherry picked from commit 471ee4832209e986029b9fabdaad57b1eecb856b)
  21. Signed-off-by: Andy Whitcroft <[email protected]>
  22. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  23. (cherry picked from commit 3c5771a43d8f00e53081871027fea891a091ff5e)
  24. Signed-off-by: Fabian Grünbichler <[email protected]>
  25. ---
  26. arch/x86/entry/entry_64.S | 11 +++++++----
  27. 1 file changed, 7 insertions(+), 4 deletions(-)
  28. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  29. index 87be1cd1fa88..4eff3aca54ed 100644
  30. --- a/arch/x86/entry/entry_64.S
  31. +++ b/arch/x86/entry/entry_64.S
  32. @@ -1572,11 +1572,14 @@ end_repeat_nmi:
  33. nmi_swapgs:
  34. SWAPGS_UNSAFE_STACK
  35. nmi_restore:
  36. - RESTORE_EXTRA_REGS
  37. - RESTORE_C_REGS
  38. + POP_EXTRA_REGS
  39. + POP_C_REGS
  40. - /* Point RSP at the "iret" frame. */
  41. - REMOVE_PT_GPREGS_FROM_STACK 6*8
  42. + /*
  43. + * Skip orig_ax and the "outermost" frame to point RSP at the "iret"
  44. + * at the "iret" frame.
  45. + */
  46. + addq $6*8, %rsp
  47. /*
  48. * Clear "NMI executing". Set DF first so that we can easily
  49. --
  50. 2.14.2