mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Mike Rapoport <rppt@kernel.org>, nakixii <nakixii@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Peter Xu <peterx@redhat.com>,
	Suren Baghdasaryan <surenb@google.com>,
	Lokesh Gidra <lokeshgidra@google.com>,
	Kairui Song <kasong@tencent.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/userfaultfd: check exclusivity of the page being moved
Date: Tue, 17 Nov 2026 22:16:15 +0100	[thread overview]
Message-ID: <0efca67f-5ab1-4ab2-8607-abf94366d384@kernel.org> (raw)
In-Reply-To: <20261117195228.2675563-1-rppt@kernel.org>

On 11/17/26 20:52, Mike Rapoport wrote:
> On Wed, Nov 18, 2026 at 03:18:53AM +0800, nakixii wrote:
>> 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.
> 
> COW reuse of PTE-mapped large folios only appeared with commit
> 1da190f4d0a6 ("mm: Copy-on-Write (COW) reuse support for PTE-mapped
> THP"), so this scenario didn't exist when UFFDIO_MOVE was added.

You could construct something odd even without that by using MADV_DONTFORK on
parts of the folio to then fork().

-- 
Cheers,

David

  reply	other threads:[~2026-11-17 21:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:18 nakixii
2026-11-17 19:52 ` Mike Rapoport
2026-11-17 21:16   ` David Hildenbrand (Arm) [this message]
2026-11-17 21:15 ` David Hildenbrand (Arm)

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=0efca67f-5ab1-4ab2-8607-abf94366d384@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lokeshgidra@google.com \
    --cc=nakixii@gmail.com \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®