From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>, Jan Kara <jack@suse.cz>,
Jingyi Sun <1045704958@qq.com>,
"Liam R. Howlett" <liam@infradead.org>,
Matthew Wilcox <willy@infradead.org>,
Michal Hocko <mhocko@suse.com>,
Muhammad Usama Anjum <usama.anjum@arm.com>,
Peter Xu <peterx@redhat.com>,
Suren Baghdasaryan <surenb@google.com>,
Vlastimil Babka <vbabka@kernel.org>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
nvdimm@lists.linux.dev
Subject: Re: [PATCH 3/3] mm/memory: don't upgrade non-present PTEs in insert_page_into_pte_locked()
Date: Wed, 18 Nov 2026 14:27:41 +0000 [thread overview]
Message-ID: <av21s_WAXAzEtLyX@gremlin> (raw)
In-Reply-To: <20261117-uffd-dax-async-wp-fix-v1-3-c9a30f27f452@kernel.org>
On Tue, Nov 17, 2026 at 05:58:34PM +0200, Mike Rapoport (Microsoft) wrote:
> On a write fault insert_page_into_pte_locked() assumes that a non-empty PTE
> maps a page, compares its PFN with the page being inserted and upgrades
> the PTE to writable.
>
> Since guard regions are allowed in file-backed mappings,
> MADV_GUARD_INSTALL can put a guard marker into a PTE of a DAX mapping
> after the DAX fault handler found that PTE empty and before it inserts
> the page.
>
> vmf_insert_page_mkwrite() then extracts a PFN from the marker, hits the
> WARN_ON_ONCE() and fails the fault with SIGBUS instead of the SIGSEGV
> expected on access to a guard region:
>
> WARNING: mm/memory.c:2489 at insert_page_into_pte_locked+0x47e/0x490, CPU#3: guard-race/157
> RIP: 0010:insert_page_into_pte_locked+0x47e/0x490
> Call Trace:
> <TASK>
> insert_page+0x6f/0xc0
> vmf_insert_page_mkwrite+0x31/0x60
> dax_fault_iter+0x3be/0x5f0
> dax_iomap_pte_fault+0x1b8/0x390
> ext4_dax_huge_fault+0x1a4/0x2f0
> __do_fault+0x34/0xc0
> do_fault+0x179/0x610
> __handle_mm_fault+0x8ca/0x1250
> handle_mm_fault+0xb4/0x290
> do_user_addr_fault+0x15f/0x730
> exc_page_fault+0x83/0x190
> asm_exc_page_fault+0x26/0x30
>
> Return -EBUSY for non-present PTEs on write faults like it's done for read
> faults, so that the fault is retried and handle_pte_marker() deals with
> the marker.
>
> Fixes: f807123d578d ("mm: allow guard regions in file-backed and read-only mappings")
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Seems similar to some of my recent work :) what a hive of alien facehuggers
insert_page() and friends are...
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
> mm/memory.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 66ad58429967..a80925c61706 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -2474,7 +2474,7 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
> return 0;
> }
>
> - if (!mkwrite)
> + if (!mkwrite || !pte_present(pteval))
> return -EBUSY;
>
> /*
>
> --
> 2.53.0
>
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-11-18 14:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 15:58 [PATCH 0/3] mm/memory: fix handling of PTE markers " Mike Rapoport (Microsoft)
2026-11-17 15:58 ` [PATCH 1/3] mm/memory: install new PTEs first " Mike Rapoport (Microsoft)
2026-11-17 15:58 ` [PATCH 2/3] mm/memory: replace uffd-wp markers " Mike Rapoport (Microsoft)
2026-11-17 15:58 ` [PATCH 3/3] mm/memory: don't upgrade non-present PTEs " Mike Rapoport (Microsoft)
2026-11-18 10:05 ` David Hildenbrand (Arm)
2026-11-18 14:27 ` Lorenzo Stoakes (ARM) [this message]
2026-11-18 14:47 ` David Hildenbrand (Arm)
2026-11-17 16:22 ` [PATCH 0/3] mm/memory: fix handling of PTE markers " David Hildenbrand (Arm)
2026-11-17 19:31 ` Mike Rapoport
2026-11-17 20:19 ` David Hildenbrand (Arm)
2026-11-18 14:56 ` (subset) " David Hildenbrand
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=av21s_WAXAzEtLyX@gremlin \
--to=ljs@kernel.org \
--cc=1045704958@qq.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=jack@suse.cz \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=nvdimm@lists.linux.dev \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=usama.anjum@arm.com \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
/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®