]> Git Repo - linux.git/commitdiff
userfaultfd: avoid huge_zero_page in UFFDIO_MOVE
authorSuren Baghdasaryan <[email protected]>
Fri, 12 Jan 2024 01:39:35 +0000 (17:39 -0800)
committerAndrew Morton <[email protected]>
Fri, 12 Jan 2024 23:20:49 +0000 (15:20 -0800)
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/[email protected]
Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Reported-by: [email protected]
Signed-off-by: Suren Baghdasaryan <[email protected]>
Acked-by: David Hildenbrand <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Cc: Peter Xu <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
mm/userfaultfd.c

index 216ab4c8621f6ba38e480ea791e7fb0283cf4944..20e3b0d9cf7ed0d59d86a11b2472f0e138160692 100644 (file)
@@ -1393,6 +1393,12 @@ ssize_t move_pages(struct userfaultfd_ctx *ctx, struct mm_struct *mm,
                                err = -ENOENT;
                                break;
                        }
+                       /* Avoid moving zeropages for now */
+                       if (is_huge_zero_pmd(*src_pmd)) {
+                               spin_unlock(ptl);
+                               err = -EBUSY;
+                               break;
+                       }
 
                        /* Check if we can move the pmd without splitting it. */
                        if (move_splits_huge_pmd(dst_addr, src_addr, src_start + len) ||
This page took 0.050502 seconds and 4 git commands to generate.