diff options
author | Andrea Arcangeli <aarcange@redhat.com> | 2017-02-22 15:43:49 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-02-22 16:41:29 -0800 |
commit | 9cc90c664a65f9b6b9f3ce1c719f1308539427bd (patch) | |
tree | ee2938c04ca31d34ee8fe2afbbe84e7510a1d3e9 /mm/shmem.c | |
parent | 419624daf0e827452837177c4b983dc0f1b6429f (diff) | |
download | linux-9cc90c664a65f9b6b9f3ce1c719f1308539427bd.tar.gz linux-9cc90c664a65f9b6b9f3ce1c719f1308539427bd.tar.bz2 linux-9cc90c664a65f9b6b9f3ce1c719f1308539427bd.zip |
userfaultfd: shmem: lock the page before adding it to pagecache
A VM_BUG_ON triggered on the shmem selftest.
Link: http://lkml.kernel.org/r/20161216144821.5183-36-aarcange@redhat.com
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: Michael Rapoport <RAPOPORT@il.ibm.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/shmem.c')
-rw-r--r-- | mm/shmem.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index ab6644194fee..4e5e7a57e5b4 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2245,6 +2245,10 @@ int shmem_mcopy_atomic_pte(struct mm_struct *dst_mm, *pagep = NULL; } + VM_BUG_ON(PageLocked(page) || PageSwapBacked(page)); + __SetPageLocked(page); + __SetPageSwapBacked(page); + ret = mem_cgroup_try_charge(page, dst_mm, gfp, &memcg, false); if (ret) goto out_release; @@ -2294,6 +2298,7 @@ out_release_uncharge_unlock: out_release_uncharge: mem_cgroup_cancel_charge(page, memcg, false); out_release: + unlock_page(page); put_page(page); out_dec_used_blocks: if (sbinfo->max_blocks) |