diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 56eaae9dac1a..1f47ff83a9c2 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -921,6 +921,10 @@ static int userfaultfd_release(struct inode *inode, struct file *file) prev = vma; continue; } + /* Reset ptes for the whole vma range if wr-protected */ + if (userfaultfd_wp(vma)) + uffd_wp_range(vma, vma->vm_start, + vma->vm_end - vma->vm_start, false); new_flags = vma->vm_flags & ~__VM_UFFD_FLAGS; prev = vma_merge(&vmi, mm, prev, vma->vm_start, vma->vm_end, new_flags, vma->anon_vma,