All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: nakixii <nakixii@gmail.com>, "Andrew Morton" <akpm@linux-foundation.org>
Cc: "Mike Rapoport" <rppt@kernel.org>, "Peter Xu" <peterx@redhat.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Suren Baghdasaryan" <surenb@google.com>,
	"Lokesh Gidra" <lokeshgidra@google.com>,
	"Kairui Song" <kasong@tencent.com>,
	linux-mm@kvack.org
Subject: Re: [PATCH] mm/userfaultfd: check exclusivity of the page being moved
Date: Wed, 18 Nov 2026 19:21:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-221844@kernel.org> (raw)
In-Reply-To: <20261117191853.1314834-1-nakixii@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mm/userfaultfd: Signed-off-by trailer uses handle instead of
  real name
--

commit 888d38f960fc9868b79456db2818f9a7357f85a5
Author: nakixii <nakixii@gmail.com>

> mm/userfaultfd: check exclusivity of the page being moved
>
> move_pages_ptes() gets the folio of a present source PTE and then checks
> PageAnonExclusive() on the first page of that folio.  PG_anon_exclusive
> is per page, so for a PTE-mapped large folio this can give the wrong
> answer for the page that is actually being moved.
>
> This happens after fork().  fork() clears the flag on every page of the
> folio.  Once the child exits, a write fault in the parent can reuse the
> large folio, and do_wp_page() sets the flag again only on the faulting
> page.  Reclaim can leave the same state behind when try_to_unmap()
> replaces the earlier pages with swap entries and then fails on a later
> one.
>
> Moving that page with UFFDIO_MOVE then fails with -EBUSY, even though
> the folio could be split and the page moved.  Callers that fall back to
> UFFDIO_COPY on -EBUSY end up copying instead.
>
> Check the flag on the page mapped by the source PTE and get the folio
> from that page.  Locking, refcounting and the split-and-retry path stay
> the same.  The batched path only handles small folios and the PMD path
> already checks the page the PMD maps, so they don't need this.
>
> Tested in an x86_64 KVM guest on mm-unstable with only 64K anonymous
> mTHP enabled: map a 64K-aligned region backed by one large folio, fork,
> let the child exit, write to the sixth page and move it.  Without this
> patch all 20 moves failed with -EBUSY.  With it all 20 worked and the
> data was correct.  Moving the first page right after fork() still fails
> with -EBUSY, as it should.  The move tests in uffd-unit-tests pass with
> and without the patch (the two swap tests were skipped, there is no
> swap in the guest).  I didn't reproduce the reclaim case and didn't
> test arm64.
>
> I found this with Claude Code while debugging an out-of-tree swap
> backend, and it wrote the first version of the fix.  This version, the
> changelog and the reproducer were also done with AI help.  I've reviewed
> all of it.
>
> Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
> Link: https://lore.kernel.org/all/20261116110122.309748-1-nakixii@gmail.com/
> Signed-off-by: nakixii <nakixii@gmail.com>

[Severity: High]
Per Documentation/process/submitting-patches.rst, the Author header and
Signed-off-by trailer must use a real name rather than a handle or
username ("nakixii") to satisfy the Developer's Certificate of Origin.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117191853.1314834-1-nakixii@gmail.com?part=1


      parent reply	other threads:[~2026-11-18 19:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:18 [PATCH] mm/userfaultfd: check exclusivity of the page being moved nakixii
2026-11-17 19:52 ` Mike Rapoport
2026-11-17 21:16   ` David Hildenbrand (Arm)
2026-11-17 21:15 ` David Hildenbrand (Arm)
2026-11-18 19:21 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-221844@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linux-mm@kvack.org \
    --cc=lokeshgidra@google.com \
    --cc=nakixii@gmail.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=surenb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.