linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: aarcange@redhat.com, akpm@linux-foundation.org,
	bgeffon@google.com, joel@joelfernandes.org,
	kirill.shutemov@linux.intel.com, linux-mm@kvack.org,
	lokeshgidra@google.com, minchan@kernel.org,
	mm-commits@vger.kernel.org, mst@redhat.com, sonnyrao@google.com,
	torvalds@linux-foundation.org, vbabka@suse.cz
Subject: [patch 4/7] userfaultfd: fix remap event with MREMAP_DONTUNMAP
Date: Wed, 13 May 2020 17:50:44 -0700	[thread overview]
Message-ID: <20200514005044.jvPMHXtzZ%akpm@linux-foundation.org> (raw)
In-Reply-To: <20200513175005.1f4839360c18c0238df292d1@linux-foundation.org>

From: Brian Geffon <bgeffon@google.com>
Subject: userfaultfd: fix remap event with MREMAP_DONTUNMAP

A user is not required to set a new address when using MREMAP_DONTUNMAP as
it can be used without MREMAP_FIXED.  When doing so the remap event will
use new_addr which may not have been set and we didn't propagate it back
other then in the return value of remap_to.

Because ret is always the new address it's probably more correct to use it
rather than new_addr on the remap_event_complete call, and it resolves
this bug.

Link: http://lkml.kernel.org/r/20200506172158.218366-1-bgeffon@google.com
Fixes: e346b3813067d4b ("mm/mremap: add MREMAP_DONTUNMAP to mremap()")
Signed-off-by: Brian Geffon <bgeffon@google.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: "Michael S . Tsirkin" <mst@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Sonny Rao <sonnyrao@google.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/mremap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/mremap.c~userfaultfd-fix-remap-event-with-mremap_dontunmap
+++ a/mm/mremap.c
@@ -794,7 +794,7 @@ out:
 	if (locked && new_len > old_len)
 		mm_populate(new_addr + old_len, new_len - old_len);
 	userfaultfd_unmap_complete(mm, &uf_unmap_early);
-	mremap_userfaultfd_complete(&uf, addr, new_addr, old_len);
+	mremap_userfaultfd_complete(&uf, addr, ret, old_len);
 	userfaultfd_unmap_complete(mm, &uf_unmap);
 	return ret;
 }
_


  parent reply	other threads:[~2020-05-14  0:50 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14  0:50 incoming Andrew Morton
2020-05-14  0:50 ` [patch 1/7] mm, memcg: fix inconsistent oom event behavior Andrew Morton
2020-05-14  0:50 ` [patch 2/7] epoll: call final ep_events_available() check under the lock Andrew Morton
2020-05-14  0:50 ` [patch 3/7] mm/gup: fix fixup_user_fault() on multiple retries Andrew Morton
2020-05-14  0:50 ` Andrew Morton [this message]
2020-05-14  0:50 ` [patch 5/7] ipc/util.c: sysvipc_find_ipc() incorrectly updates position index Andrew Morton
2020-05-14  0:50 ` [patch 6/7] kasan: consistently disable debugging features Andrew Morton
2020-05-14  0:50 ` [patch 7/7] kasan: add missing functions declarations to kasan.h Andrew Morton
2020-05-14  3:31 ` mmotm 2020-05-13-20-30 uploaded Andrew Morton
2020-05-14 15:30   ` mmotm 2020-05-13-20-30 uploaded (gpu/drm/bridge/sil-sii8620) Randy Dunlap
2020-05-14 15:32   ` mmotm 2020-05-13-20-30 uploaded (objtool warnings) Randy Dunlap
2020-05-14 15:33     ` Randy Dunlap
2020-05-28 15:54     ` Josh Poimboeuf
2020-05-28 17:04       ` Josh Poimboeuf
2020-05-28 17:20     ` Peter Zijlstra
2020-05-29 13:57       ` Christoph Hellwig
2020-05-29 14:35         ` Peter Zijlstra
2020-05-29 14:53           ` Peter Zijlstra
2020-05-29 15:33             ` Peter Zijlstra
2020-05-29 16:05               ` Josh Poimboeuf
2020-05-29 16:12                 ` Peter Zijlstra
2020-05-29 16:50                   ` Josh Poimboeuf
2020-05-29 16:54                     ` Peter Zijlstra
2020-05-29 17:25                       ` [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations Josh Poimboeuf
2020-05-29 18:29                         ` Randy Dunlap
2020-05-29 19:31                     ` mmotm 2020-05-13-20-30 uploaded (objtool warnings) Linus Torvalds
2020-05-29 20:08                       ` Al Viro
2020-05-29 20:14                         ` Al Viro
2020-05-15 23:30 ` mmotm 2020-05-15-16-29 uploaded Andrew Morton
2020-05-16  5:53   ` Stephen Rothwell
2020-05-18 23:15     ` Stephen Rothwell
2020-05-20  4:48 ` mmotm 2020-05-19-21-47 uploaded Andrew Morton
2020-05-22  3:43 ` mmotm 2020-05-21-20-42 uploaded Andrew Morton
2020-05-22 16:26   ` mmotm 2020-05-21-20-42 uploaded (atomisp) Randy Dunlap
2020-05-23  3:36 ` mmotm 2020-05-22-20-35 uploaded Andrew Morton
2020-05-23 15:08   ` mmotm 2020-05-22-20-35 uploaded (phy/intel/phy-intel-combo.c) Randy Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200514005044.jvPMHXtzZ%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=aarcange@redhat.com \
    --cc=bgeffon@google.com \
    --cc=joel@joelfernandes.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-mm@kvack.org \
    --cc=lokeshgidra@google.com \
    --cc=minchan@kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=sonnyrao@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).