diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2017-12-14 06:27:29 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-12-22 14:13:01 -0500 |
commit | c10e83f598d08046dd1ebc8360d4bb12d802d51b (patch) | |
tree | b1b8d341aefdd1869b07c33193499eb9019c09db | |
parent | 4831b779403a836158917d59a7ca880483c67378 (diff) |
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>
-rw-r--r-- | arch/powerpc/include/asm/mmu_context.h | 5 | ||||
-rw-r--r-- | arch/um/include/asm/mmu_context.h | 3 | ||||
-rw-r--r-- | arch/unicore32/include/asm/mmu_context.h | 5 | ||||
-rw-r--r-- | arch/x86/include/asm/mmu_context.h | 4 | ||||
-rw-r--r-- | include/asm-generic/mm_hooks.h | 5 | ||||
-rw-r--r-- | 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 492d8140a395..44fdf4786638 100644 --- a/arch/powerpc/include/asm/mmu_context.h +++ b/arch/powerpc/include/asm/mmu_context.h | |||
@@ -114,9 +114,10 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, | |||
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | static inline void arch_dup_mmap(struct mm_struct *oldmm, | 117 | static inline int arch_dup_mmap(struct mm_struct *oldmm, |
118 | struct mm_struct *mm) | 118 | struct mm_struct *mm) |
119 | { | 119 | { |
120 | return 0; | ||
120 | } | 121 | } |
121 | 122 | ||
122 | static inline void arch_exit_mmap(struct mm_struct *mm) | 123 | 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); | |||
15 | /* | 15 | /* |
16 | * Needed since we do not use the asm-generic/mm_hooks.h: | 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 | uml_setup_stubs(mm); | 20 | uml_setup_stubs(mm); |
21 | return 0; | ||
21 | } | 22 | } |
22 | extern void arch_exit_mmap(struct mm_struct *mm); | 23 | extern void arch_exit_mmap(struct mm_struct *mm); |
23 | static inline void arch_unmap(struct mm_struct *mm, | 24 | 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 { \ | |||
81 | } \ | 81 | } \ |
82 | } while (0) | 82 | } while (0) |
83 | 83 | ||
84 | static inline void arch_dup_mmap(struct mm_struct *oldmm, | 84 | static inline int arch_dup_mmap(struct mm_struct *oldmm, |
85 | struct mm_struct *mm) | 85 | struct mm_struct *mm) |
86 | { | 86 | { |
87 | return 0; | ||
87 | } | 88 | } |
88 | 89 | ||
89 | static inline void arch_unmap(struct mm_struct *mm, | 90 | 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 6d16d15d09a0..c76162439c8a 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -176,10 +176,10 @@ do { \ | |||
176 | } while (0) | 176 | } while (0) |
177 | #endif | 177 | #endif |
178 | 178 | ||
179 | static inline void arch_dup_mmap(struct mm_struct *oldmm, | 179 | static inline int arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm) |
180 | struct mm_struct *mm) | ||
181 | { | 180 | { |
182 | paravirt_arch_dup_mmap(oldmm, mm); | 181 | paravirt_arch_dup_mmap(oldmm, mm); |
182 | return 0; | ||
183 | } | 183 | } |
184 | 184 | ||
185 | static inline void arch_exit_mmap(struct mm_struct *mm) | 185 | 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 ea189d88a3cc..8ac4e68a12f0 100644 --- a/include/asm-generic/mm_hooks.h +++ b/include/asm-generic/mm_hooks.h | |||
@@ -7,9 +7,10 @@ | |||
7 | #ifndef _ASM_GENERIC_MM_HOOKS_H | 7 | #ifndef _ASM_GENERIC_MM_HOOKS_H |
8 | #define _ASM_GENERIC_MM_HOOKS_H | 8 | #define _ASM_GENERIC_MM_HOOKS_H |
9 | 9 | ||
10 | static inline void arch_dup_mmap(struct mm_struct *oldmm, | 10 | static inline int arch_dup_mmap(struct mm_struct *oldmm, |
11 | struct mm_struct *mm) | 11 | struct mm_struct *mm) |
12 | { | 12 | { |
13 | return 0; | ||
13 | } | 14 | } |
14 | 15 | ||
15 | static inline void arch_exit_mmap(struct mm_struct *mm) | 16 | static inline void arch_exit_mmap(struct mm_struct *mm) |
diff --git a/kernel/fork.c b/kernel/fork.c index 07cc743698d3..500ce64517d9 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -721,8 +721,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, | |||
721 | goto out; | 721 | goto out; |
722 | } | 722 | } |
723 | /* a new mm has just been created */ | 723 | /* a new mm has just been created */ |
724 | arch_dup_mmap(oldmm, mm); | 724 | retval = arch_dup_mmap(oldmm, mm); |
725 | retval = 0; | ||
726 | out: | 725 | out: |
727 | up_write(&mm->mmap_sem); | 726 | up_write(&mm->mmap_sem); |
728 | flush_tlb_mm(oldmm); | 727 | flush_tlb_mm(oldmm); |