Commit a94720bf authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Linus Torvalds

userfaultfd: use vma_is_anonymous

Cleanup the vma->vm_ops usage.

Side note: it would be more robust if vma_is_anonymous() would also
check that vm_flags hasn't VM_PFNMAP set.

Link: http://lkml.kernel.org/r/20161216144821.5183-5-aarcange@redhat.comSigned-off-by: default avatarAndrea 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8474901a
...@@ -830,7 +830,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, ...@@ -830,7 +830,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
/* check not compatible vmas */ /* check not compatible vmas */
ret = -EINVAL; ret = -EINVAL;
if (cur->vm_ops) if (!vma_is_anonymous(cur))
goto out_unlock; goto out_unlock;
/* /*
...@@ -855,7 +855,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, ...@@ -855,7 +855,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
do { do {
cond_resched(); cond_resched();
BUG_ON(vma->vm_ops); BUG_ON(!vma_is_anonymous(vma));
BUG_ON(vma->vm_userfaultfd_ctx.ctx && BUG_ON(vma->vm_userfaultfd_ctx.ctx &&
vma->vm_userfaultfd_ctx.ctx != ctx); vma->vm_userfaultfd_ctx.ctx != ctx);
...@@ -981,7 +981,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, ...@@ -981,7 +981,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
* provides for more strict behavior to notice * provides for more strict behavior to notice
* unregistration errors. * unregistration errors.
*/ */
if (cur->vm_ops) if (!vma_is_anonymous(cur))
goto out_unlock; goto out_unlock;
found = true; found = true;
...@@ -995,7 +995,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, ...@@ -995,7 +995,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
do { do {
cond_resched(); cond_resched();
BUG_ON(vma->vm_ops); BUG_ON(!vma_is_anonymous(vma));
/* /*
* Nothing to do: this vma is already registered into this * Nothing to do: this vma is already registered into this
......
...@@ -197,7 +197,7 @@ static __always_inline ssize_t __mcopy_atomic(struct mm_struct *dst_mm, ...@@ -197,7 +197,7 @@ static __always_inline ssize_t __mcopy_atomic(struct mm_struct *dst_mm,
* FIXME: only allow copying on anonymous vmas, tmpfs should * FIXME: only allow copying on anonymous vmas, tmpfs should
* be added. * be added.
*/ */
if (dst_vma->vm_ops) if (!vma_is_anonymous(dst_vma))
goto out_unlock; goto out_unlock;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment