From: Nadav Amit Date: Tue, 4 Sep 2018 22:45:41 +0000 (-0700) Subject: mm: respect arch_dup_mmap() return value X-Git-Tag: v4.18.8~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a5d47d5faa3003ad1fbfc16c71122ab17f45c16;p=thirdparty%2Fkernel%2Fstable.git mm: respect arch_dup_mmap() return value commit 1ed0cc5a01a4d868d9907ce96468c4b4c6709556 upstream. Commit d70f2a14b72a ("include/linux/sched/mm.h: uninline mmdrop_async(), etc") ignored the return value of arch_dup_mmap(). As a result, on x86, a failure to duplicate the LDT (e.g. due to memory allocation error) would leave the duplicated memory mapping in an inconsistent state. Fix by using the return value, as it was before the change. Link: http://lkml.kernel.org/r/20180823051229.211856-1-namit@vmware.com Fixes: d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc") Signed-off-by: Nadav Amit Acked-by: Michal Hocko Cc: Signed-off-by: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/fork.c b/kernel/fork.c index 9cf8add7038d8..8ed48ca2cc437 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -549,8 +549,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);