From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Alex Williamson <alex@shazbot.org>, Peter Xu <peterx@redhat.com>,
Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>, Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kiryl Shutsemau <kas@kernel.org>, Wei Liu <wei.liu@kernel.org>,
Roman Kisel <romank@linux.microsoft.com>,
Saurabh Sengar <ssengar@linux.microsoft.com>,
Naman Jain <namjain@linux.microsoft.com>,
Michael Kelley <mhklinux@outlook.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
"Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
"T.J. Mercier" <tjmercier@google.com>,
Eliav Farber <farbere@amazon.com>,
"Gregory Price (Meta)" <gourry@gourry.net>
Subject: Re: [PATCH v3 0/4] mm: fix races between huge and non-huge faults in PFN mappings
Date: Thu, 26 Nov 2026 14:26:37 +0100 [thread overview]
Message-ID: <dc62bf2a-9188-4cc6-9850-14ab3a2e5274@kernel.org> (raw)
In-Reply-To: <20261125-huge-pfnmap-fault-races-v3-0-bbc44489341b@kernel.org>
On 11/25/26 16:48, Lorenzo Stoakes (ARM) wrote:
> A driver that implements both ->fault and ->huge_fault must anticipate
> concurrent use of both.
>
> This can happen, for example, if a user calls prctl(PR_SET_THP_DISABLE)
> concurrent with faulting, as that only holds the mmap write lock and thus
> does not exclude faulting threads stabilised by VMA lock.
>
> A number of places in the code that implements huge PFN support fail to
> take this into account correctly, which this series aims to address.
>
> Generally the shape of the issue is that faulting the same empty page table
> entry can result in the ->fault and ->huge_fault handlers racing and the
> loser finding something they didn't expect.
>
> The fault code must tolerate this, but fails to in 3 places:
>
> 1. walk_to_pmd() asserts, without the PMD lock, that the PMD entry is not
> huge, so a VM_BUG_ON() triggers. [ vfio-pci, nvgrace-gpu ]
>
> 2. insert_pfn() treats a failure to map the PTE table as an allocation
> failure and reports OOM, causing kernel accesses to the range to
> spuriously fail with -EFAULT. [ vfio-pci, nvgrace-gpu ]
>
> 3. insert_pmd() and insert_pud() assume a populated entry is huge and
> compare its PFN on write fault, warning when that of a page table does
> not match. [ mshv_vtl, drm_gem_shmem, panthor ]
>
> This was originally reported and fixed by Eliav Farber in [0], this series
> reworks patches 1-3 of that one.
>
> Patch 4 of that series (x86 PAT encoding of huge PFN mappings) is dropped -
> it is unrelated to the above, no in-tree driver is affected by it, and it
> needs a different approach which is better pursued separately with the x86
> maintainers.
>
> All three issues were reproduced on x86-64 under QEMU using vfio-pci in
> no-IOMMU mode on an ivshmem BAR, with 6 threads faulting the same address
> in each PMD or PUD aligned range of the mapping while another toggles
> PR_SET_THP_DISABLE (note that vfio-pci had to be modified to pass the write
> flag to reproduce the third issue).
>
> Without this series the BUG is hit immediately, with only patches 1 and 2
> applied tens of thousands of -EFAULTs are observed within seconds, and with
> patches 1-3 (and the vfio-pci modification) both warnings fire immediately.
>
> With the series applied 30 second runs at each of PMD and PUD size complete
> with none of the above, with or without the vfio-pci modification.
>
> [0]: https://lore.kernel.org/all/20261112051440.16140-1-farbere@amazon.com/
>
Dropped v2, tried to apply v3, doesn't apply.
Against which branch was it based? mm/hotfixes-stable?
I this really urgent stuff or can this wait until the next merge window?
I had v2 staged for the next merge window.
--
Cheers,
David
next prev parent reply other threads:[~2026-11-26 13:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 15:48 [PATCH v3 0/4] mm: fix races between huge and non-huge faults in PFN mappings Lorenzo Stoakes (ARM)
2026-11-25 15:48 ` [PATCH v3 1/4] mm: update walk_to_pmd() to explicitly return an error Lorenzo Stoakes (ARM)
2026-11-25 15:48 ` [PATCH v3 2/4] mm/memory: remove racy huge PMD assertion from walk_to_pmd() Lorenzo Stoakes (ARM)
2026-11-25 15:48 ` [PATCH v3 3/4] mm/memory: do not report OOM if insert_pfn() races a huge fault Lorenzo Stoakes (ARM)
2026-11-25 15:48 ` [PATCH v3 4/4] mm/huge_memory: only compare PFNs of huge entries on huge fault insert Lorenzo Stoakes (ARM)
2026-11-26 13:26 ` David Hildenbrand (Arm) [this message]
2026-11-26 14:01 ` [PATCH v3 0/4] mm: fix races between huge and non-huge faults in PFN mappings Lorenzo Stoakes (ARM)
2026-11-26 14:15 ` David Hildenbrand (Arm)
2026-11-26 14:23 ` Lorenzo Stoakes (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=dc62bf2a-9188-4cc6-9850-14ab3a2e5274@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=azpijr@gmail.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=dev.jain@arm.com \
--cc=farbere@amazon.com \
--cc=gourry@gourry.net \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhklinux@outlook.com \
--cc=mhocko@suse.com \
--cc=namjain@linux.microsoft.com \
--cc=nico.pache@linux.dev \
--cc=peterx@redhat.com \
--cc=romank@linux.microsoft.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=ssengar@linux.microsoft.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=tjmercier@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@kernel.org \
--cc=wei.liu@kernel.org \
--cc=ziy@nvidia.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