ext4: fix potential htree corruption when growing large_dir directories
[linux-2.6-microblaze.git] / fs / userfaultfd.c
index dd7a6c6..f6e0f0c 100644 (file)
@@ -1267,8 +1267,7 @@ static inline bool vma_can_userfault(struct vm_area_struct *vma,
        }
 
        if (vm_flags & VM_UFFD_MINOR) {
-               /* FIXME: Add minor fault interception for shmem. */
-               if (!is_vm_hugetlb_page(vma))
+               if (!(is_vm_hugetlb_page(vma) || vma_is_shmem(vma)))
                        return false;
        }
 
@@ -1304,8 +1303,12 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
        vm_flags = 0;
        if (uffdio_register.mode & UFFDIO_REGISTER_MODE_MISSING)
                vm_flags |= VM_UFFD_MISSING;
-       if (uffdio_register.mode & UFFDIO_REGISTER_MODE_WP)
+       if (uffdio_register.mode & UFFDIO_REGISTER_MODE_WP) {
+#ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
+               goto out;
+#endif
                vm_flags |= VM_UFFD_WP;
+       }
        if (uffdio_register.mode & UFFDIO_REGISTER_MODE_MINOR) {
 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
                goto out;
@@ -1941,7 +1944,11 @@ static int userfaultfd_api(struct userfaultfd_ctx *ctx,
        /* report all available features and ioctls to userland */
        uffdio_api.features = UFFD_API_FEATURES;
 #ifndef CONFIG_HAVE_ARCH_USERFAULTFD_MINOR
-       uffdio_api.features &= ~UFFD_FEATURE_MINOR_HUGETLBFS;
+       uffdio_api.features &=
+               ~(UFFD_FEATURE_MINOR_HUGETLBFS | UFFD_FEATURE_MINOR_SHMEM);
+#endif
+#ifndef CONFIG_HAVE_ARCH_USERFAULTFD_WP
+       uffdio_api.features &= ~UFFD_FEATURE_PAGEFAULT_FLAG_WP;
 #endif
        uffdio_api.ioctls = UFFD_API_IOCTLS;
        ret = -EFAULT;