Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arch, mm: Allow arch_dup_mmap() to fail

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 <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirsky <luto@kernel.org>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Laight <David.Laight@aculab.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Eduardo Valentin <eduval@amazon.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: aliguori@amazon.com
Cc: dan.j.williams@intel.com
Cc: hughd@google.com
Cc: keescook@google.com
Cc: kirill.shutemov@linux.intel.com
Cc: linux-mm@kvack.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Thomas Gleixner and committed by
Ingo Molnar
c10e83f5 4831b779

+14 -11
+3 -2
arch/powerpc/include/asm/mmu_context.h
··· 114 114 #endif 115 115 } 116 116 117 - static inline void arch_dup_mmap(struct mm_struct *oldmm, 118 - struct mm_struct *mm) 117 + static inline int arch_dup_mmap(struct mm_struct *oldmm, 118 + struct mm_struct *mm) 119 119 { 120 + return 0; 120 121 } 121 122 122 123 static inline void arch_exit_mmap(struct mm_struct *mm)
+2 -1
arch/um/include/asm/mmu_context.h
··· 15 15 /* 16 16 * Needed since we do not use the asm-generic/mm_hooks.h: 17 17 */ 18 - static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) 18 + static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) 19 19 { 20 20 uml_setup_stubs(mm); 21 + return 0; 21 22 } 22 23 extern void arch_exit_mmap(struct mm_struct *mm); 23 24 static inline void arch_unmap(struct mm_struct *mm,
+3 -2
arch/unicore32/include/asm/mmu_context.h
··· 81 81 } \ 82 82 } while (0) 83 83 84 - static inline void arch_dup_mmap(struct mm_struct *oldmm, 85 - struct mm_struct *mm) 84 + static inline int arch_dup_mmap(struct mm_struct *oldmm, 85 + struct mm_struct *mm) 86 86 { 87 + return 0; 87 88 } 88 89 89 90 static inline void arch_unmap(struct mm_struct *mm,
+2 -2
arch/x86/include/asm/mmu_context.h
··· 176 176 } while (0) 177 177 #endif 178 178 179 - static inline void arch_dup_mmap(struct mm_struct *oldmm, 180 - struct mm_struct *mm) 179 + static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) 181 180 { 182 181 paravirt_arch_dup_mmap(oldmm, mm); 182 + return 0; 183 183 } 184 184 185 185 static inline void arch_exit_mmap(struct mm_struct *mm)
+3 -2
include/asm-generic/mm_hooks.h
··· 7 7 #ifndef _ASM_GENERIC_MM_HOOKS_H 8 8 #define _ASM_GENERIC_MM_HOOKS_H 9 9 10 - static inline void arch_dup_mmap(struct mm_struct *oldmm, 11 - struct mm_struct *mm) 10 + static inline int arch_dup_mmap(struct mm_struct *oldmm, 11 + struct mm_struct *mm) 12 12 { 13 + return 0; 13 14 } 14 15 15 16 static inline void arch_exit_mmap(struct mm_struct *mm)
+1 -2
kernel/fork.c
··· 721 721 goto out; 722 722 } 723 723 /* a new mm has just been created */ 724 - arch_dup_mmap(oldmm, mm); 725 - retval = 0; 724 + retval = arch_dup_mmap(oldmm, mm); 726 725 out: 727 726 up_write(&mm->mmap_sem); 728 727 flush_tlb_mm(oldmm);