Revert "mm: protect VMA modifications using VMA sequence count"

This reverts commit 06219e6c87.

Bug: 128240262
Change-Id: If31a4c81badd891e6ca5740dbd022b5edbe47254
Signed-off-by: Minchan Kim <minchan@google.com>
[dereference23: Forward port to msm-5.4]
Signed-off-by: Alexander Winkowski <dereference23@outlook.com>
This commit is contained in:
Minchan Kim 2019-03-11 11:42:01 +09:00 • committed by Alexander Winkowski
commit bb4e220b57
No known key found for this signature in database
GPG key ID: 72762A66704CDE44
9 changed files with 42 additions and 94 deletions

View file

@ -678,11 +678,8 @@ int dup_userfaultfd(struct vm_area_struct *vma, struct list_head *fcs)
octx = vma->vm_userfaultfd_ctx.ctx;
if (!octx || !(octx->features & UFFD_FEATURE_EVENT_FORK)) {
vm_write_begin(vma);
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
WRITE_ONCE(vma->vm_flags,
vma->vm_flags & ~__VM_UFFD_FLAGS);
vm_write_end(vma);
vma->vm_flags &= ~__VM_UFFD_FLAGS;
return 0;
}
@ -924,10 +921,8 @@ static int userfaultfd_release(struct inode *inode, struct file *file)
else
prev = vma;
}
vm_write_begin(vma);
WRITE_ONCE(vma->vm_flags, new_flags);
vma->vm_flags = new_flags;
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
vm_write_end(vma);
}
up_write(&mm->mmap_sem);
mmput(mm);
@ -1499,10 +1494,8 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
* the next vma was merged into the current one and
* the current one has not been updated yet.
*/
vm_write_begin(vma);
WRITE_ONCE(vma->vm_flags, vma_pad_fixup_flags(vma, new_flags));
vma->vm_flags = vma_pad_fixup_flags(vma, new_flags);
vma->vm_userfaultfd_ctx.ctx = ctx;
vm_write_end(vma);
if (is_vm_hugetlb_page(vma) && uffd_disable_huge_pmd_share(vma))
hugetlb_unshare_all_pmds(vma);
@ -1674,10 +1667,8 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
* the next vma was merged into the current one and
* the current one has not been updated yet.
*/
vm_write_begin(vma);
WRITE_ONCE(vma->vm_flags, vma_pad_fixup_flags(vma, new_flags));
vma->vm_flags = vma_pad_fixup_flags(vma, new_flags);
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
vm_write_end(vma);
skip:
prev = vma;