0106-x86-entry-64-Shorten-TEST-instructions.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From de4c79dbea1d23e58752c189586c5f5b751fa142 Mon Sep 17 00:00:00 2001
  2. From: Borislav Petkov <[email protected]>
  3. Date: Thu, 2 Nov 2017 13:09:26 +0100
  4. Subject: [PATCH 106/242] x86/entry/64: Shorten TEST instructions
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. Convert TESTL to TESTB and save 3 bytes per callsite.
  10. No functionality change.
  11. Signed-off-by: Borislav Petkov <[email protected]>
  12. Cc: Andy Lutomirski <[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/[email protected]
  19. Signed-off-by: Ingo Molnar <[email protected]>
  20. (cherry picked from commit 1e4c4f610f774df6088d7c065b2dd4d22adba698)
  21. Signed-off-by: Andy Whitcroft <[email protected]>
  22. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  23. (cherry picked from commit 2b5cfca36261d4ce45ebfdf2602d65201fa3c780)
  24. Signed-off-by: Fabian Grünbichler <[email protected]>
  25. ---
  26. arch/x86/entry/entry_64.S | 4 ++--
  27. 1 file changed, 2 insertions(+), 2 deletions(-)
  28. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  29. index 05501c781c20..2491b3b25b9a 100644
  30. --- a/arch/x86/entry/entry_64.S
  31. +++ b/arch/x86/entry/entry_64.S
  32. @@ -620,7 +620,7 @@ GLOBAL(retint_user)
  33. GLOBAL(swapgs_restore_regs_and_return_to_usermode)
  34. #ifdef CONFIG_DEBUG_ENTRY
  35. /* Assert that pt_regs indicates user mode. */
  36. - testl $3, CS(%rsp)
  37. + testb $3, CS(%rsp)
  38. jnz 1f
  39. ud2
  40. 1:
  41. @@ -653,7 +653,7 @@ retint_kernel:
  42. GLOBAL(restore_regs_and_return_to_kernel)
  43. #ifdef CONFIG_DEBUG_ENTRY
  44. /* Assert that pt_regs indicates kernel mode. */
  45. - testl $3, CS(%rsp)
  46. + testb $3, CS(%rsp)
  47. jz 1f
  48. ud2
  49. 1:
  50. --
  51. 2.14.2