From: Liam R. Howlett Date: Mon, 27 Oct 2025 19:35:09 +0000 (-0400) Subject: mm/userfaultfd: Remove !anon and !shmem check from mfill_atomic() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3492b684f16cbc3537da9464712521b2d32e58e8;p=users%2Fjedix%2Flinux-maple.git mm/userfaultfd: Remove !anon and !shmem check from mfill_atomic() 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 --- diff --git a/mm/shmem.c b/mm/shmem.c index 28c679130f68..385dd39f9337 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -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; } diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index ca716bef7a50..bc82a67d4782 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -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;