0090-x86-entry-64-Shrink-paranoid_exit_restore-and-make-l.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From d8fdea47d7fc1177aa0843a49dc89422ac6f4fea Mon Sep 17 00:00:00 2001
  2. From: Andy Lutomirski <[email protected]>
  3. Date: Thu, 2 Nov 2017 00:59:02 -0700
  4. Subject: [PATCH 090/242] x86/entry/64: Shrink paranoid_exit_restore and make
  5. labels local
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. paranoid_exit_restore was a copy of restore_regs_and_return_to_kernel.
  11. Merge them and make the paranoid_exit internal labels local.
  12. Keeping .Lparanoid_exit makes the code a bit shorter because it
  13. allows a 2-byte jnz instead of a 5-byte jnz.
  14. Saves 96 bytes of text.
  15. ( This is still a bit suboptimal in a non-CONFIG_TRACE_IRQFLAGS
  16. kernel, but fixing that would make the code rather messy. )
  17. Signed-off-by: Andy Lutomirski <[email protected]>
  18. Cc: Borislav Petkov <[email protected]>
  19. Cc: Brian Gerst <[email protected]>
  20. Cc: Dave Hansen <[email protected]>
  21. Cc: Linus Torvalds <[email protected]>
  22. Cc: Peter Zijlstra <[email protected]>
  23. Cc: Thomas Gleixner <[email protected]>
  24. Link: http://lkml.kernel.org/r/510d66a1895cda9473c84b1086f0bb974f22de6a.1509609304.git.luto@kernel.org
  25. Signed-off-by: Ingo Molnar <[email protected]>
  26. (cherry picked from commit e53178328c9b96fbdbc719e78c93b5687ee007c3)
  27. Signed-off-by: Andy Whitcroft <[email protected]>
  28. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  29. (cherry picked from commit fb53fe10add935c3d0eb63199e43426eaf3b4299)
  30. Signed-off-by: Fabian Grünbichler <[email protected]>
  31. ---
  32. arch/x86/entry/entry_64.S | 13 +++++--------
  33. 1 file changed, 5 insertions(+), 8 deletions(-)
  34. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  35. index a1a86e782a0e..6995f7e08aa1 100644
  36. --- a/arch/x86/entry/entry_64.S
  37. +++ b/arch/x86/entry/entry_64.S
  38. @@ -1136,17 +1136,14 @@ ENTRY(paranoid_exit)
  39. DISABLE_INTERRUPTS(CLBR_ANY)
  40. TRACE_IRQS_OFF_DEBUG
  41. testl %ebx, %ebx /* swapgs needed? */
  42. - jnz paranoid_exit_no_swapgs
  43. + jnz .Lparanoid_exit_no_swapgs
  44. TRACE_IRQS_IRETQ
  45. SWAPGS_UNSAFE_STACK
  46. - jmp paranoid_exit_restore
  47. -paranoid_exit_no_swapgs:
  48. + jmp .Lparanoid_exit_restore
  49. +.Lparanoid_exit_no_swapgs:
  50. TRACE_IRQS_IRETQ_DEBUG
  51. -paranoid_exit_restore:
  52. - RESTORE_EXTRA_REGS
  53. - RESTORE_C_REGS
  54. - REMOVE_PT_GPREGS_FROM_STACK 8
  55. - INTERRUPT_RETURN
  56. +.Lparanoid_exit_restore:
  57. + jmp restore_regs_and_return_to_kernel
  58. END(paranoid_exit)
  59. /*
  60. --
  61. 2.14.2