Skip to content

Commit 5d4747a

Browse files
surenbaghdasaryanakpm00
authored andcommitted
userfaultfd: avoid huge_zero_page in UFFDIO_MOVE
While testing UFFDIO_MOVE ioctl, syzbot triggered VM_BUG_ON_PAGE caused by a call to PageAnonExclusive() with a huge_zero_page as a parameter. UFFDIO_MOVE does not yet handle zeropages and returns EBUSY when one is encountered. Add an early huge_zero_page check in the PMD move path to avoid this situation. Link: https://lkml.kernel.org/r/20240112013935.1474648-1-surenb@google.com Fixes: adef440 ("userfaultfd: UFFDIO_MOVE uABI") Reported-by: syzbot+705209281e36404998f6@syzkaller.appspotmail.com Signed-off-by: Suren Baghdasaryan <surenb@google.com> Acked-by: David Hildenbrand <david@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent aa8f919 commit 5d4747a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

mm/userfaultfd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,6 +1393,12 @@ ssize_t move_pages(struct userfaultfd_ctx *ctx, struct mm_struct *mm,
13931393
err = -ENOENT;
13941394
break;
13951395
}
1396+
/* Avoid moving zeropages for now */
1397+
if (is_huge_zero_pmd(*src_pmd)) {
1398+
spin_unlock(ptl);
1399+
err = -EBUSY;
1400+
break;
1401+
}
13961402

13971403
/* Check if we can move the pmd without splitting it. */
13981404
if (move_splits_huge_pmd(dst_addr, src_addr, src_start + len) ||

0 commit comments

Comments
 (0)