mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Rik van Riel <riel@surriel.com>
Cc: Yeoreum Yun <yeoreum.yun@arm.com>, Jason Gunthorpe <jgg@ziepe.ca>,
	John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Lorenzo Stoakes <ljs@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>
Subject: Re: [PATCH] mm/gup: unshare-check every page of a pte batch
Date: Thu, 19 Nov 2026 17:20:28 +0100	[thread overview]
Message-ID: <55dece20-678c-4726-9abe-cad5fd4dccfc@kernel.org> (raw)
In-Reply-To: <81418de6-3c5e-4f5c-a447-98f338f5096f@kernel.org>

On 11/19/26 17:16, David Hildenbrand (Arm) wrote:
> On 11/19/26 16:57, Rik van Riel wrote:
>> A write pin over a PTE batch can hand back pages that a later
>> write fault replaces under the pin holder: the process writes to
>> the copy, the holder keeps the old page:
>>
>>     pin holder                          process (mm owner)
>>     pin all 16 for write
>>       batch passes unchecked
> 
> All PTEs must be writable or all pages must be PageAnonExclusive
> 
>>                                         write to a tail page
>>                                           fault copies it elsewhere
> 
> Which copies only if !pte_write() && !PageAnonExclusive
> 
>>     read pinned page -> stale
>>
>> For every FOLL_WRITE call the helper returns the whole run on
>> the head page's credentials, never reaching the per-page loop below.
>> After fork, a FOLL_FORCE write unsharing only the head leaves
>> the tail pages read-only and non-exclusive behind identical
>> PTEs, which batching (PTE bits only, never the exclusivity flag)
>> covers at once.
>>
>> A page pinned for write must be exclusive to the pinning process,
>> and one vetted PTE proves that for one page only. FOLL_GET and
>> single-page FOLL_WRITE keep the shortcut; multi-page callers run
>> the per-page check. Writable batches and GUP-fast are unchanged.
>>
>> Without this fix, the pin holder sees stale page content,
>> with it the pin and program address map the same page.
>>
>> Signed-off-by: Rik van Riel <riel@surriel.com>
>> ---
>> This fix applies on gup-7.5-ptebatch in mm/core.git
> 
> I was confused when I read the above.
> 
> I fed this to Claude and it told me
> 
> 1) The path it describes can't happen.
> 
> 2) The patch fixes nothing.
> 
> 3) The changelog contradicts itself.

It argued that because "Writable batches and GUP-fast are unchanged.", which
also caused the biggest confusion on my end.

So this smells like a bug in your new GUP user instead? Or some incompatibility
with the helper when used in different context (that would surprise me).

-- 
Cheers,

David

      reply	other threads:[~2026-11-19 16:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 15:57 Rik van Riel
2026-11-19 16:16 ` David Hildenbrand (Arm)
2026-11-19 16:20   ` David Hildenbrand (Arm) [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=55dece20-678c-4726-9abe-cad5fd4dccfc@kernel.org \
    --to=david@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=jgg@ziepe.ca \
    --cc=jhubbard@nvidia.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=peterx@redhat.com \
    --cc=riel@surriel.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=yeoreum.yun@arm.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®