linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: respect arch_dup_mmap() return value
@ 2018-08-23  5:12 Nadav Amit
  2018-08-23  8:57 ` Michal Hocko
  0 siblings, 1 reply; 2+ messages in thread
From: Nadav Amit @ 2018-08-23  5:12 UTC (permalink / raw)
  To: Michal Hocko; +Cc: linux-kernel, linux-mm, Nadav Amit, Andrew Morton, stable

Commit d70f2a14b72a4 ("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 regarding the return value, as it was before the change.

Fixes: d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc")
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Nadav Amit <namit@vmware.com>
---
 kernel/fork.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/fork.c b/kernel/fork.c
index 1b27babc4c78..4527d1d331de 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);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: respect arch_dup_mmap() return value
  2018-08-23  5:12 [PATCH] mm: respect arch_dup_mmap() return value Nadav Amit
@ 2018-08-23  8:57 ` Michal Hocko
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2018-08-23  8:57 UTC (permalink / raw)
  To: Nadav Amit; +Cc: linux-kernel, linux-mm, Andrew Morton, stable

On Wed 22-08-18 22:12:29, Nadav Amit wrote:
> Commit d70f2a14b72a4 ("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 regarding the return value, as it was before the change.

Ohh, well spotted! I have a vague recollection I didn't really like the
patch. For other reasons. I didn't get to review it properly back then
because I didn't have much time and I didn't have a high motivation
because I simple disagreed with the patch.

> Fixes: d70f2a14b72a4 ("include/linux/sched/mm.h: uninline mmdrop_async(), etc")
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: stable@vger.kernel.org
> Signed-off-by: Nadav Amit <namit@vmware.com>

Acked-by: Michal Hocko <mhocko@suse.com>

Thanks!

> ---
>  kernel/fork.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 1b27babc4c78..4527d1d331de 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);
> -- 
> 2.17.1
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-23  8:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23  5:12 [PATCH] mm: respect arch_dup_mmap() return value Nadav Amit
2018-08-23  8:57 ` Michal Hocko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).