diff options
author | Mike Rapoport <rppt@linux.vnet.ibm.com> | 2017-02-08 10:27:36 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2017-02-09 21:53:04 +1100 |
commit | daa7c6d199cb873045a64971a1a98cc6c4ab880e (patch) | |
tree | 2ffae4f19cb15d99653327ed022d0bb9c35ed092 /mm | |
parent | 911ef9dc8185d166e899b4206b0c4e41a1f4f53e (diff) |
userfaultfd: mcopy_atomic: update cases returning -ENOENT
As Andrea commented in [1], if the VMA covering the address was unmapped,
we may end up with a VMA a way above the faulting address. In this case we
would like to return -ENOENT to allow uffd monitor detection of VMA
removal.
[1] http://www.spinics.net/lists/linux-mm/msg121267.html
Link: http://lkml.kernel.org/r/20170207150249.GA6709@rapoport-lnx
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hillf Danton <hillf.zj@alibaba-inc.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Pavel Emelyanov <xemul@virtuozzo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/userfaultfd.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index b861cf993a00..cf4345603490 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -206,6 +206,10 @@ retry: if (!dst_vma->vm_userfaultfd_ctx.ctx) goto out_unlock; + if (dst_start < dst_vma->vm_start || + dst_start + len > dst_vma->vm_end) + goto out_unlock; + err = -EINVAL; if (vma_hpagesize != vma_kernel_pagesize(dst_vma)) goto out_unlock; @@ -216,9 +220,6 @@ retry: */ if (dst_vma->vm_flags & VM_SHARED) goto out_unlock; - if (dst_start < dst_vma->vm_start || - dst_start + len > dst_vma->vm_end) - goto out_unlock; } if (WARN_ON(dst_addr & (vma_hpagesize - 1) || @@ -385,13 +386,14 @@ retry: if (!dst_vma->vm_userfaultfd_ctx.ctx) goto out_unlock; - err = -EINVAL; - if (!vma_is_shmem(dst_vma) && dst_vma->vm_flags & VM_SHARED) - goto out_unlock; if (dst_start < dst_vma->vm_start || dst_start + len > dst_vma->vm_end) goto out_unlock; + err = -EINVAL; + if (!vma_is_shmem(dst_vma) && dst_vma->vm_flags & VM_SHARED) + goto out_unlock; + /* * If this is a HUGETLB vma, pass off to appropriate routine */ |