]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/userfaultfd: Remove !anon and !shmem check from mfill_atomic()
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 27 Oct 2025 19:35:09 +0000 (15:35 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 30 Oct 2025 16:26:26 +0000 (12:26 -0400)
The check for !anon && !shmem happens after hugetlb is branched off into
its own function, so it only applies to anon and shmem types.  Move the
check to the uffd ops is_dst_valid() for both those types.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
mm/shmem.c
mm/userfaultfd.c

index 28c679130f68b406617f98c52646ed422bc71a50..385dd39f93370b00805a8a61af928e3688912824 100644 (file)
@@ -3153,6 +3153,9 @@ static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
 static ssize_t shmem_is_dst_valid(struct vm_area_struct *dst_vma,
                unsigned long dst_start, unsigned long len)
 {
+       if (!vma_is_anonymous(dst_vma) && !vma_is_shmem(dst_vma))
+           return -EINVAL;
+
        return 0;
 }
 
index ca716bef7a50e981d6d8ba800d6ff8f4d799acb2..bc82a67d478215f306367b1b4475062a16a0cd9c 100644 (file)
@@ -500,6 +500,9 @@ static pmd_t *mm_alloc_pmd(struct mm_struct *mm, unsigned long address)
 static ssize_t uffd_def_is_dst_valid(struct vm_area_struct *dst_vma,
                unsigned long dst_start, unsigned long len)
 {
+       if (!vma_is_anonymous(dst_vma) && !vma_is_shmem(dst_vma))
+               return -EINVAL;
+
        return 0;
 }
 
@@ -794,8 +797,6 @@ retry:
                                             src_start, len, flags);
 
        err = -EINVAL;
-       if (!vma_is_anonymous(dst_vma) && !vma_is_shmem(dst_vma))
-               goto out_unlock;
        if (!vma_is_shmem(dst_vma) &&
            uffd_flags_mode_is(flags, MFILL_ATOMIC_CONTINUE))
                goto out_unlock;