0085-ptrace-x86-Make-user_64bit_mode-available-to-32-bit-.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. From 34b5c16ae093e5663c398c87569793bfbec1c7ca Mon Sep 17 00:00:00 2001
  2. From: Ricardo Neri <[email protected]>
  3. Date: Fri, 27 Oct 2017 13:25:30 -0700
  4. Subject: [PATCH 085/242] ptrace,x86: Make user_64bit_mode() available to
  5. 32-bit builds
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. CVE-2017-5754
  10. In its current form, user_64bit_mode() can only be used when CONFIG_X86_64
  11. is selected. This implies that code built with CONFIG_X86_64=n cannot use
  12. it. If a piece of code needs to be built for both CONFIG_X86_64=y and
  13. CONFIG_X86_64=n and wants to use this function, it needs to wrap it in
  14. an #ifdef/#endif; potentially, in multiple places.
  15. This can be easily avoided with a single #ifdef/#endif pair within
  16. user_64bit_mode() itself.
  17. Suggested-by: Borislav Petkov <[email protected]>
  18. Signed-off-by: Ricardo Neri <[email protected]>
  19. Signed-off-by: Thomas Gleixner <[email protected]>
  20. Reviewed-by: Borislav Petkov <[email protected]>
  21. Cc: "Michael S. Tsirkin" <[email protected]>
  22. Cc: Peter Zijlstra <[email protected]>
  23. Cc: Dave Hansen <[email protected]>
  24. Cc: [email protected]
  25. Cc: Adrian Hunter <[email protected]>
  26. Cc: Paul Gortmaker <[email protected]>
  27. Cc: Huang Rui <[email protected]>
  28. Cc: Qiaowei Ren <[email protected]>
  29. Cc: Shuah Khan <[email protected]>
  30. Cc: Kees Cook <[email protected]>
  31. Cc: Jonathan Corbet <[email protected]>
  32. Cc: Jiri Slaby <[email protected]>
  33. Cc: Dmitry Vyukov <[email protected]>
  34. Cc: "Ravi V. Shankar" <[email protected]>
  35. Cc: Chris Metcalf <[email protected]>
  36. Cc: Brian Gerst <[email protected]>
  37. Cc: Arnaldo Carvalho de Melo <[email protected]>
  38. Cc: Andy Lutomirski <[email protected]>
  39. Cc: Colin Ian King <[email protected]>
  40. Cc: Chen Yucong <[email protected]>
  41. Cc: Adam Buchbinder <[email protected]>
  42. Cc: Vlastimil Babka <[email protected]>
  43. Cc: Lorenzo Stoakes <[email protected]>
  44. Cc: Masami Hiramatsu <[email protected]>
  45. Cc: Paolo Bonzini <[email protected]>
  46. Cc: Andrew Morton <[email protected]>
  47. Cc: Thomas Garnier <[email protected]>
  48. Link: https://lkml.kernel.org/r/1509135945-13762-4-git-send-email-ricardo.neri-calderon@linux.intel.com
  49. (cherry picked from commit e27c310af5c05cf876d9cad006928076c27f54d4)
  50. Signed-off-by: Andy Whitcroft <[email protected]>
  51. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  52. (cherry picked from commit 20ddf08f867d3d96788299cd2fb7676590d64250)
  53. Signed-off-by: Fabian Grünbichler <[email protected]>
  54. ---
  55. arch/x86/include/asm/ptrace.h | 6 +++++-
  56. 1 file changed, 5 insertions(+), 1 deletion(-)
  57. diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
  58. index 2b5d686ea9f3..ea78a8438a8a 100644
  59. --- a/arch/x86/include/asm/ptrace.h
  60. +++ b/arch/x86/include/asm/ptrace.h
  61. @@ -115,9 +115,9 @@ static inline int v8086_mode(struct pt_regs *regs)
  62. #endif
  63. }
  64. -#ifdef CONFIG_X86_64
  65. static inline bool user_64bit_mode(struct pt_regs *regs)
  66. {
  67. +#ifdef CONFIG_X86_64
  68. #ifndef CONFIG_PARAVIRT
  69. /*
  70. * On non-paravirt systems, this is the only long mode CPL 3
  71. @@ -128,8 +128,12 @@ static inline bool user_64bit_mode(struct pt_regs *regs)
  72. /* Headers are too twisted for this to go in paravirt.h. */
  73. return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
  74. #endif
  75. +#else /* !CONFIG_X86_64 */
  76. + return false;
  77. +#endif
  78. }
  79. +#ifdef CONFIG_X86_64
  80. #define current_user_stack_pointer() current_pt_regs()->sp
  81. #define compat_user_stack_pointer() current_pt_regs()->sp
  82. #endif
  83. --
  84. 2.14.2