| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- From 45f502dae27e55fa46c65e71c226eec759ea7385 Mon Sep 17 00:00:00 2001
- From: Thomas Gleixner <[email protected]>
- Date: Thu, 14 Dec 2017 12:27:29 +0100
- Subject: [PATCH 168/232] arch, mm: Allow arch_dup_mmap() to fail
- MIME-Version: 1.0
- Content-Type: text/plain; charset=UTF-8
- Content-Transfer-Encoding: 8bit
- CVE-2017-5754
- In order to sanitize the LDT initialization on x86 arch_dup_mmap() must be
- allowed to fail. Fix up all instances.
- Signed-off-by: Thomas Gleixner <[email protected]>
- Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
- Cc: Andy Lutomirski <[email protected]>
- Cc: Andy Lutomirsky <[email protected]>
- Cc: Boris Ostrovsky <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Borislav Petkov <[email protected]>
- Cc: Brian Gerst <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: Dave Hansen <[email protected]>
- Cc: David Laight <[email protected]>
- Cc: Denys Vlasenko <[email protected]>
- Cc: Eduardo Valentin <[email protected]>
- Cc: Greg KH <[email protected]>
- Cc: H. Peter Anvin <[email protected]>
- Cc: Josh Poimboeuf <[email protected]>
- Cc: Juergen Gross <[email protected]>
- Cc: Linus Torvalds <[email protected]>
- Cc: Peter Zijlstra <[email protected]>
- Cc: Will Deacon <[email protected]>
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Cc: [email protected]
- Signed-off-by: Ingo Molnar <[email protected]>
- (cherry picked from commit c10e83f598d08046dd1ebc8360d4bb12d802d51b)
- Signed-off-by: Andy Whitcroft <[email protected]>
- Signed-off-by: Kleber Sacilotto de Souza <[email protected]>
- (cherry picked from commit b812abb61437eda1f5718a95085d67902f813f2f)
- Signed-off-by: Fabian Grünbichler <[email protected]>
- ---
- arch/powerpc/include/asm/mmu_context.h | 5 +++--
- arch/um/include/asm/mmu_context.h | 3 ++-
- arch/unicore32/include/asm/mmu_context.h | 5 +++--
- arch/x86/include/asm/mmu_context.h | 4 ++--
- include/asm-generic/mm_hooks.h | 5 +++--
- kernel/fork.c | 3 +--
- 6 files changed, 14 insertions(+), 11 deletions(-)
- diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
- index 35bec1c5bd5a..60afcc94e673 100644
- --- a/arch/powerpc/include/asm/mmu_context.h
- +++ b/arch/powerpc/include/asm/mmu_context.h
- @@ -185,9 +185,10 @@ static inline void enter_lazy_tlb(struct mm_struct *mm,
- #endif
- }
-
- -static inline void arch_dup_mmap(struct mm_struct *oldmm,
- - struct mm_struct *mm)
- +static inline int arch_dup_mmap(struct mm_struct *oldmm,
- + struct mm_struct *mm)
- {
- + return 0;
- }
-
- static inline void arch_exit_mmap(struct mm_struct *mm)
- diff --git a/arch/um/include/asm/mmu_context.h b/arch/um/include/asm/mmu_context.h
- index b668e351fd6c..fca34b2177e2 100644
- --- a/arch/um/include/asm/mmu_context.h
- +++ b/arch/um/include/asm/mmu_context.h
- @@ -15,9 +15,10 @@ extern void uml_setup_stubs(struct mm_struct *mm);
- /*
- * Needed since we do not use the asm-generic/mm_hooks.h:
- */
- -static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
- +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
- {
- uml_setup_stubs(mm);
- + return 0;
- }
- extern void arch_exit_mmap(struct mm_struct *mm);
- static inline void arch_unmap(struct mm_struct *mm,
- diff --git a/arch/unicore32/include/asm/mmu_context.h b/arch/unicore32/include/asm/mmu_context.h
- index 59b06b48f27d..5c205a9cb5a6 100644
- --- a/arch/unicore32/include/asm/mmu_context.h
- +++ b/arch/unicore32/include/asm/mmu_context.h
- @@ -81,9 +81,10 @@ do { \
- } \
- } while (0)
-
- -static inline void arch_dup_mmap(struct mm_struct *oldmm,
- - struct mm_struct *mm)
- +static inline int arch_dup_mmap(struct mm_struct *oldmm,
- + struct mm_struct *mm)
- {
- + return 0;
- }
-
- static inline void arch_unmap(struct mm_struct *mm,
- diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
- index efc530642f7d..9be54d9c04c4 100644
- --- a/arch/x86/include/asm/mmu_context.h
- +++ b/arch/x86/include/asm/mmu_context.h
- @@ -175,10 +175,10 @@ do { \
- } while (0)
- #endif
-
- -static inline void arch_dup_mmap(struct mm_struct *oldmm,
- - struct mm_struct *mm)
- +static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
- {
- paravirt_arch_dup_mmap(oldmm, mm);
- + return 0;
- }
-
- static inline void arch_exit_mmap(struct mm_struct *mm)
- diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h
- index 41e5b6784b97..7a2980f4e3e6 100644
- --- a/include/asm-generic/mm_hooks.h
- +++ b/include/asm-generic/mm_hooks.h
- @@ -6,9 +6,10 @@
- #ifndef _ASM_GENERIC_MM_HOOKS_H
- #define _ASM_GENERIC_MM_HOOKS_H
-
- -static inline void arch_dup_mmap(struct mm_struct *oldmm,
- - struct mm_struct *mm)
- +static inline int arch_dup_mmap(struct mm_struct *oldmm,
- + struct mm_struct *mm)
- {
- + return 0;
- }
-
- static inline void arch_exit_mmap(struct mm_struct *mm)
- diff --git a/kernel/fork.c b/kernel/fork.c
- index 8efc6b4466e3..1d907772b9d2 100644
- --- a/kernel/fork.c
- +++ b/kernel/fork.c
- @@ -712,8 +712,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
- goto out;
- }
- /* a new mm has just been created */
- - arch_dup_mmap(oldmm, mm);
- - retval = 0;
- + retval = arch_dup_mmap(oldmm, mm);
- out:
- up_write(&mm->mmap_sem);
- flush_tlb_mm(oldmm);
- --
- 2.14.2
|