0079-x86-asm-Don-t-use-the-confusing-.ifeq-directive.patch 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. From 05096d194a52721b3f4add5f854fc62296b82e72 Mon Sep 17 00:00:00 2001
  2. From: Josh Poimboeuf <[email protected]>
  3. Date: Fri, 20 Oct 2017 11:21:35 -0500
  4. Subject: [PATCH 079/231] x86/asm: Don't use the confusing '.ifeq' directive
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. I find the '.ifeq <expression>' directive to be confusing. Reading it
  10. quickly seems to suggest its opposite meaning, or that it's missing an
  11. argument.
  12. Improve readability by replacing all of its x86 uses with
  13. '.if <expression> == 0'.
  14. Signed-off-by: Josh Poimboeuf <[email protected]>
  15. Cc: Andrei Vagin <[email protected]>
  16. Cc: Andy Lutomirski <[email protected]>
  17. Cc: Linus Torvalds <[email protected]>
  18. Cc: Peter Zijlstra <[email protected]>
  19. Cc: Thomas Gleixner <[email protected]>
  20. Link: http://lkml.kernel.org/r/757da028e802c7e98d23fbab8d234b1063e161cf.1508516398.git.jpoimboe@redhat.com
  21. Signed-off-by: Ingo Molnar <[email protected]>
  22. (cherry picked from commit 82c62fa0c49aa305104013cee4468772799bb391)
  23. Signed-off-by: Andy Whitcroft <[email protected]>
  24. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  25. (cherry picked from commit 981dedac1061fb47d0b04e07f6752be195d7e41a)
  26. Signed-off-by: Fabian Grünbichler <[email protected]>
  27. ---
  28. arch/x86/entry/entry_64.S | 2 +-
  29. arch/x86/kernel/head_32.S | 2 +-
  30. arch/x86/kernel/head_64.S | 2 +-
  31. 3 files changed, 3 insertions(+), 3 deletions(-)
  32. diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
  33. index 2e4fc6425f47..34adfe0221d2 100644
  34. --- a/arch/x86/entry/entry_64.S
  35. +++ b/arch/x86/entry/entry_64.S
  36. @@ -830,7 +830,7 @@ ENTRY(\sym)
  37. ASM_CLAC
  38. - .ifeq \has_error_code
  39. + .if \has_error_code == 0
  40. pushq $-1 /* ORIG_RAX: no syscall to restart */
  41. .endif
  42. diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
  43. index 1f85ee8f9439..337a65377baf 100644
  44. --- a/arch/x86/kernel/head_32.S
  45. +++ b/arch/x86/kernel/head_32.S
  46. @@ -435,7 +435,7 @@ ENTRY(early_idt_handler_array)
  47. # 24(%rsp) error code
  48. i = 0
  49. .rept NUM_EXCEPTION_VECTORS
  50. - .ifeq (EXCEPTION_ERRCODE_MASK >> i) & 1
  51. + .if ((EXCEPTION_ERRCODE_MASK >> i) & 1) == 0
  52. pushl $0 # Dummy error code, to make stack frame uniform
  53. .endif
  54. pushl $i # 20(%esp) Vector number
  55. diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
  56. index 12daaa0b187f..a2d8541b1da4 100644
  57. --- a/arch/x86/kernel/head_64.S
  58. +++ b/arch/x86/kernel/head_64.S
  59. @@ -258,7 +258,7 @@ ENDPROC(start_cpu0)
  60. ENTRY(early_idt_handler_array)
  61. i = 0
  62. .rept NUM_EXCEPTION_VECTORS
  63. - .ifeq (EXCEPTION_ERRCODE_MASK >> i) & 1
  64. + .if ((EXCEPTION_ERRCODE_MASK >> i) & 1) == 0
  65. UNWIND_HINT_IRET_REGS
  66. pushq $0 # Dummy error code, to make stack frame uniform
  67. .else
  68. --
  69. 2.14.2