0168-arch-mm-Allow-arch_dup_mmap-to-fail.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. From 45f502dae27e55fa46c65e71c226eec759ea7385 Mon Sep 17 00:00:00 2001
  2. From: Thomas Gleixner <[email protected]>
  3. Date: Thu, 14 Dec 2017 12:27:29 +0100
  4. Subject: [PATCH 168/232] arch, mm: Allow arch_dup_mmap() to fail
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. CVE-2017-5754
  9. In order to sanitize the LDT initialization on x86 arch_dup_mmap() must be
  10. allowed to fail. Fix up all instances.
  11. Signed-off-by: Thomas Gleixner <[email protected]>
  12. Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
  13. Cc: Andy Lutomirski <[email protected]>
  14. Cc: Andy Lutomirsky <[email protected]>
  15. Cc: Boris Ostrovsky <[email protected]>
  16. Cc: Borislav Petkov <[email protected]>
  17. Cc: Borislav Petkov <[email protected]>
  18. Cc: Brian Gerst <[email protected]>
  19. Cc: Dave Hansen <[email protected]>
  20. Cc: Dave Hansen <[email protected]>
  21. Cc: David Laight <[email protected]>
  22. Cc: Denys Vlasenko <[email protected]>
  23. Cc: Eduardo Valentin <[email protected]>
  24. Cc: Greg KH <[email protected]>
  25. Cc: H. Peter Anvin <[email protected]>
  26. Cc: Josh Poimboeuf <[email protected]>
  27. Cc: Juergen Gross <[email protected]>
  28. Cc: Linus Torvalds <[email protected]>
  29. Cc: Peter Zijlstra <[email protected]>
  30. Cc: Will Deacon <[email protected]>
  31. Cc: [email protected]
  32. Cc: [email protected]
  33. Cc: [email protected]
  34. Cc: [email protected]
  35. Cc: [email protected]
  36. Cc: [email protected]
  37. Signed-off-by: Ingo Molnar <[email protected]>
  38. (cherry picked from commit c10e83f598d08046dd1ebc8360d4bb12d802d51b)
  39. Signed-off-by: Andy Whitcroft <[email protected]>
  40. Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
  41. (cherry picked from commit b812abb61437eda1f5718a95085d67902f813f2f)
  42. Signed-off-by: Fabian Grünbichler <[email protected]>
  43. ---
  44. arch/powerpc/include/asm/mmu_context.h | 5 +++--
  45. arch/um/include/asm/mmu_context.h | 3 ++-
  46. arch/unicore32/include/asm/mmu_context.h | 5 +++--
  47. arch/x86/include/asm/mmu_context.h | 4 ++--
  48. include/asm-generic/mm_hooks.h | 5 +++--
  49. kernel/fork.c | 3 +--
  50. 6 files changed, 14 insertions(+), 11 deletions(-)
  51. diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
  52. index 35bec1c5bd5a..60afcc94e673 100644
  53. --- a/arch/powerpc/include/asm/mmu_context.h
  54. +++ b/arch/powerpc/include/asm/mmu_context.h
  55. @@ -185,9 +185,10 @@ static inline void enter_lazy_tlb(struct mm_struct *mm,
  56. #endif
  57. }
  58. -static inline void arch_dup_mmap(struct mm_struct *oldmm,
  59. - struct mm_struct *mm)
  60. +static inline int arch_dup_mmap(struct mm_struct *oldmm,
  61. + struct mm_struct *mm)
  62. {
  63. + return 0;
  64. }
  65. static inline void arch_exit_mmap(struct mm_struct *mm)
  66. diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h
  67. index b668e351fd6c..fca34b2177e2 100644
  68. --- a/arch/um/include/asm/mmu_context.h
  69. +++ b/arch/um/include/asm/mmu_context.h
  70. @@ -15,9 +15,10 @@ extern void uml_setup_stubs(struct mm_struct *mm);
  71. /*
  72. * Needed since we do not use the asm-generic/mm_hooks.h:
  73. */
  74. -static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
  75. +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
  76. {
  77. uml_setup_stubs(mm);
  78. + return 0;
  79. }
  80. extern void arch_exit_mmap(struct mm_struct *mm);
  81. static inline void arch_unmap(struct mm_struct *mm,
  82. diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h
  83. index 59b06b48f27d..5c205a9cb5a6 100644
  84. --- a/arch/unicore32/include/asm/mmu_context.h
  85. +++ b/arch/unicore32/include/asm/mmu_context.h
  86. @@ -81,9 +81,10 @@ do { \
  87. } \
  88. } while (0)
  89. -static inline void arch_dup_mmap(struct mm_struct *oldmm,
  90. - struct mm_struct *mm)
  91. +static inline int arch_dup_mmap(struct mm_struct *oldmm,
  92. + struct mm_struct *mm)
  93. {
  94. + return 0;
  95. }
  96. static inline void arch_unmap(struct mm_struct *mm,
  97. diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
  98. index efc530642f7d..9be54d9c04c4 100644
  99. --- a/arch/x86/include/asm/mmu_context.h
  100. +++ b/arch/x86/include/asm/mmu_context.h
  101. @@ -175,10 +175,10 @@ do { \
  102. } while (0)
  103. #endif
  104. -static inline void arch_dup_mmap(struct mm_struct *oldmm,
  105. - struct mm_struct *mm)
  106. +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
  107. {
  108. paravirt_arch_dup_mmap(oldmm, mm);
  109. + return 0;
  110. }
  111. static inline void arch_exit_mmap(struct mm_struct *mm)
  112. diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h
  113. index 41e5b6784b97..7a2980f4e3e6 100644
  114. --- a/include/asm-generic/mm_hooks.h
  115. +++ b/include/asm-generic/mm_hooks.h
  116. @@ -6,9 +6,10 @@
  117. #ifndef _ASM_GENERIC_MM_HOOKS_H
  118. #define _ASM_GENERIC_MM_HOOKS_H
  119. -static inline void arch_dup_mmap(struct mm_struct *oldmm,
  120. - struct mm_struct *mm)
  121. +static inline int arch_dup_mmap(struct mm_struct *oldmm,
  122. + struct mm_struct *mm)
  123. {
  124. + return 0;
  125. }
  126. static inline void arch_exit_mmap(struct mm_struct *mm)
  127. diff --git a/kernel/fork.c b/kernel/fork.c
  128. index 8efc6b4466e3..1d907772b9d2 100644
  129. --- a/kernel/fork.c
  130. +++ b/kernel/fork.c
  131. @@ -712,8 +712,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
  132. goto out;
  133. }
  134. /* a new mm has just been created */
  135. - arch_dup_mmap(oldmm, mm);
  136. - retval = 0;
  137. + retval = arch_dup_mmap(oldmm, mm);
  138. out:
  139. up_write(&mm->mmap_sem);
  140. flush_tlb_mm(oldmm);
  141. --
  142. 2.14.2