Re: [PATCH] mm/gup: unshare-check every page of a pte batch
From: David Hildenbrand (Arm)
Date: Thu Nov 19 2026 - 11:16:36 EST
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@xxxxxxxxxxx>
> ---
> 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.
But you said that you had a reproducer. So now I am even more confused. :)
Can you share the reproducer and against which branch it ran?
--
Cheers,
David