* Re: [PATCH] mm/userfaultfd: reject DAX mappings
2026-11-18 10:03 [PATCH] mm/userfaultfd: reject DAX mappings David Hildenbrand (Arm)
@ 2026-11-18 14:12 ` Gregory Price (Meta)
2026-11-18 14:58 ` Mike Rapoport
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Gregory Price (Meta) @ 2026-11-18 14:12 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Andrew Morton, Mike Rapoport, Peter Xu, Muhammad Usama Anjum,
linux-mm, linux-kernel, Chris Mason, Jingyi Sun
On 2026-11-18 11:03 +0100, David Hildenbrand (Arm) wrote:
> UFFD_FEATURE_WP_ASYNC made DAX mappings eligible for userfaultfd
> write-protection, but the DAX fault paths have never fully supported it.
>
> DAX faults use vmf_insert_mixed() and vmf_insert_mixed_mkwrite(), which
> treats any non-empty PTE, including uffd-wp markers, as an existing mapping.
> A read fault on an uffd-wp marker therefore returns VM_FAULT_NOPAGE without
> replacing the marker, causing the fault to repeat indefinitely.
>
> PAGEMAP_SCAN can also write-protect a DAX PMD, but the huge DAX write-fault
> path can make it writable without clearing its uffd-wp bit, breaking async
> write tracking.
>
> Device DAX mappings requiring huge-page alignment and cannot serve PTE
> faults after UFFDIO_WRITEPROTECT has split their huge mappings.
>
> So let's just disallow DAX mappings in vma_can_userfault() entirely,
> making UFFDIO_REGISTER fail with EINVAL.
>
> Fixes: d61ea1cb0095 ("userfaultfd: UFFD_FEATURE_WP_ASYNC")
> Reported-by: Chris Mason <mason@kernel.org>
> Reported-by: Jingyi Sun <1045704958@qq.com>
> Closes: https://lore.kernel.org/all/tencent_1874C71D4177A1624528043E008DB1A5EF05@qq.com
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Gregory Price (Meta) <gourry@gourry.net>
--
~Gregory
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] mm/userfaultfd: reject DAX mappings
2026-11-18 10:03 [PATCH] mm/userfaultfd: reject DAX mappings David Hildenbrand (Arm)
2026-11-18 14:12 ` Gregory Price (Meta)
@ 2026-11-18 14:58 ` Mike Rapoport
2026-11-18 22:14 ` Jose A. Perez de Azpillaga
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Mike Rapoport @ 2026-11-18 14:58 UTC (permalink / raw)
To: David Hildenbrand (Arm)
Cc: Andrew Morton, Peter Xu, Muhammad Usama Anjum, linux-mm,
linux-kernel, Chris Mason, Jingyi Sun
On Wed, Nov 18, 2026 at 11:03:00AM +0100, David Hildenbrand (Arm) wrote:
> UFFD_FEATURE_WP_ASYNC made DAX mappings eligible for userfaultfd
> write-protection, but the DAX fault paths have never fully supported it.
>
> DAX faults use vmf_insert_mixed() and vmf_insert_mixed_mkwrite(), which
> treats any non-empty PTE, including uffd-wp markers, as an existing mapping.
> A read fault on an uffd-wp marker therefore returns VM_FAULT_NOPAGE without
> replacing the marker, causing the fault to repeat indefinitely.
>
> PAGEMAP_SCAN can also write-protect a DAX PMD, but the huge DAX write-fault
> path can make it writable without clearing its uffd-wp bit, breaking async
> write tracking.
>
> Device DAX mappings requiring huge-page alignment and cannot serve PTE
> faults after UFFDIO_WRITEPROTECT has split their huge mappings.
>
> So let's just disallow DAX mappings in vma_can_userfault() entirely,
> making UFFDIO_REGISTER fail with EINVAL.
>
> Fixes: d61ea1cb0095 ("userfaultfd: UFFD_FEATURE_WP_ASYNC")
> Reported-by: Chris Mason <mason@kernel.org>
> Reported-by: Jingyi Sun <1045704958@qq.com>
> Closes: https://lore.kernel.org/all/tencent_1874C71D4177A1624528043E008DB1A5EF05@qq.com
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
> mm/userfaultfd.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> index 169f681f9849b..6656233d5dcc7 100644
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -2131,6 +2131,9 @@ static bool vma_can_userfault(struct vm_area_struct *vma, vm_flags_t vm_flags,
> /* Only mm-backed memory can have its faults handled by userspace. */
> if (!vma_is_mm_backed(vma))
> return false;
> + /* DAX fault handlers do not support uffd-wp. */
> + if (vma_is_dax(vma))
> + return false;
> /* Core mm may discard droppable memory at any time. */
> if (vma_test_single_mask(vma, VMA_DROPPABLE))
> return false;
>
> ---
>
> base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
>
> change-id: 20261118-dax_uffd-0fb2c6d1c087
>
> --
>
> Cheers,
>
> David
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] mm/userfaultfd: reject DAX mappings
2026-11-18 10:03 [PATCH] mm/userfaultfd: reject DAX mappings David Hildenbrand (Arm)
2026-11-18 14:12 ` Gregory Price (Meta)
2026-11-18 14:58 ` Mike Rapoport
@ 2026-11-18 22:14 ` Jose A. Perez de Azpillaga
2026-11-19 12:11 ` Gupta, Pankaj
2026-11-24 9:50 ` + mm-userfaultfd-reject-dax-mappings.patch added to mm-new branch Andrew Morton
4 siblings, 0 replies; 7+ messages in thread
From: Jose A. Perez de Azpillaga @ 2026-11-18 22:14 UTC (permalink / raw)
To: David Hildenbrand (Arm), Andrew Morton, Mike Rapoport, Peter Xu,
Muhammad Usama Anjum
Cc: linux-mm, linux-kernel, Chris Mason, Jingyi Sun
On 11/18/26 11:03 AM, David Hildenbrand (Arm) wrote:
> UFFD_FEATURE_WP_ASYNC made DAX mappings eligible for userfaultfd
> write-protection, but the DAX fault paths have never fully supported it.
>
> DAX faults use vmf_insert_mixed() and vmf_insert_mixed_mkwrite(), which
> treats any non-empty PTE, including uffd-wp markers, as an existing mapping.
> A read fault on an uffd-wp marker therefore returns VM_FAULT_NOPAGE without
> replacing the marker, causing the fault to repeat indefinitely.
>
> PAGEMAP_SCAN can also write-protect a DAX PMD, but the huge DAX write-fault
> path can make it writable without clearing its uffd-wp bit, breaking async
> write tracking.
>
> Device DAX mappings requiring huge-page alignment and cannot serve PTE
> faults after UFFDIO_WRITEPROTECT has split their huge mappings.
>
> So let's just disallow DAX mappings in vma_can_userfault() entirely,
> making UFFDIO_REGISTER fail with EINVAL.
>
> Fixes: d61ea1cb0095 ("userfaultfd: UFFD_FEATURE_WP_ASYNC")
> Reported-by: Chris Mason <mason@kernel.org>
> Reported-by: Jingyi Sun <1045704958@qq.com>
> Closes: https://lore.kernel.org/all/tencent_1874C71D4177A1624528043E008DB1A5EF05@qq.com
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
--
cheers,
jose a. p-a
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] mm/userfaultfd: reject DAX mappings
2026-11-18 10:03 [PATCH] mm/userfaultfd: reject DAX mappings David Hildenbrand (Arm)
` (2 preceding siblings ...)
2026-11-18 22:14 ` Jose A. Perez de Azpillaga
@ 2026-11-19 12:11 ` Gupta, Pankaj
2026-11-19 12:23 ` David Hildenbrand (Arm)
2026-11-24 9:50 ` + mm-userfaultfd-reject-dax-mappings.patch added to mm-new branch Andrew Morton
4 siblings, 1 reply; 7+ messages in thread
From: Gupta, Pankaj @ 2026-11-19 12:11 UTC (permalink / raw)
To: David Hildenbrand (Arm), Andrew Morton, Mike Rapoport, Peter Xu,
Muhammad Usama Anjum
Cc: linux-mm, linux-kernel, Chris Mason, Jingyi Sun
> UFFD_FEATURE_WP_ASYNC made DAX mappings eligible for userfaultfd
> write-protection, but the DAX fault paths have never fully supported it.
>
> DAX faults use vmf_insert_mixed() and vmf_insert_mixed_mkwrite(), which
Should we use vmf_insert_page_mkwrite instead?
> treats any non-empty PTE, including uffd-wp markers, as an existing mapping.
> A read fault on an uffd-wp marker therefore returns VM_FAULT_NOPAGE without
> replacing the marker, causing the fault to repeat indefinitely.
>
> PAGEMAP_SCAN can also write-protect a DAX PMD, but the huge DAX write-fault
> path can make it writable without clearing its uffd-wp bit, breaking async
> write tracking.
>
> Device DAX mappings requiring huge-page alignment and cannot serve PTE
> faults after UFFDIO_WRITEPROTECT has split their huge mappings.
>
> So let's just disallow DAX mappings in vma_can_userfault() entirely,
> making UFFDIO_REGISTER fail with EINVAL.
>
> Fixes: d61ea1cb0095 ("userfaultfd: UFFD_FEATURE_WP_ASYNC")
> Reported-by: Chris Mason <mason@kernel.org>
> Reported-by: Jingyi Sun <1045704958@qq.com>
> Closes: https://lore.kernel.org/all/tencent_1874C71D4177A1624528043E008DB1A5EF05@qq.com
> Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
> ---
> mm/userfaultfd.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
> index 169f681f9849b..6656233d5dcc7 100644
> --- a/mm/userfaultfd.c
> +++ b/mm/userfaultfd.c
> @@ -2131,6 +2131,9 @@ static bool vma_can_userfault(struct vm_area_struct *vma, vm_flags_t vm_flags,
> /* Only mm-backed memory can have its faults handled by userspace. */
> if (!vma_is_mm_backed(vma))
> return false;
> + /* DAX fault handlers do not support uffd-wp. */
> + if (vma_is_dax(vma))
> + return false;
> /* Core mm may discard droppable memory at any time. */
> if (vma_test_single_mask(vma, VMA_DROPPABLE))
> return false;
>
> ---
>
> base-commit: fa4ad798f6f681031775266044ba1b0cf3c670bd
>
> change-id: 20261118-dax_uffd-0fb2c6d1c087
>
> --
>
> Cheers,
>
> David
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] mm/userfaultfd: reject DAX mappings
2026-11-19 12:11 ` Gupta, Pankaj
@ 2026-11-19 12:23 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 7+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-19 12:23 UTC (permalink / raw)
To: Gupta, Pankaj, Andrew Morton, Mike Rapoport, Peter Xu,
Muhammad Usama Anjum
Cc: linux-mm, linux-kernel, Chris Mason, Jingyi Sun
On 11/19/26 13:11, Gupta, Pankaj wrote:
>
>> UFFD_FEATURE_WP_ASYNC made DAX mappings eligible for userfaultfd
>> write-protection, but the DAX fault paths have never fully supported it.
>>
>> DAX faults use vmf_insert_mixed() and vmf_insert_mixed_mkwrite(), which
>
> Should we use vmf_insert_page_mkwrite instead?
vmf_insert_mixed_mkwrite() is getting removed concurrently, so I think it
doesn't really matter in the end in this commit.
Thanks for the review!
--
Cheers,
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* + mm-userfaultfd-reject-dax-mappings.patch added to mm-new branch
2026-11-18 10:03 [PATCH] mm/userfaultfd: reject DAX mappings David Hildenbrand (Arm)
` (3 preceding siblings ...)
2026-11-19 12:11 ` Gupta, Pankaj
@ 2026-11-24 9:50 ` Andrew Morton
4 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2026-11-24 9:50 UTC (permalink / raw)
To: mm-commits, usama.anjum, rppt, peterx, pankaj.gupta, mason,
gourry, azpijr, 1045704958, david, akpm
The patch titled
Subject: mm/userfaultfd: reject DAX mappings
has been added to the -mm mm-new branch. Its filename is
mm-userfaultfd-reject-dax-mappings.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-userfaultfd-reject-dax-mappings.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: "David Hildenbrand (Arm)" <david@kernel.org>
Subject: mm/userfaultfd: reject DAX mappings
Date: Wed, 18 Nov 2026 11:03:00 +0100
UFFD_FEATURE_WP_ASYNC made DAX mappings eligible for userfaultfd
write-protection, but the DAX fault paths have never fully supported it.
DAX faults use vmf_insert_mixed() and vmf_insert_mixed_mkwrite(), which
treats any non-empty PTE, including uffd-wp markers, as an existing
mapping. A read fault on an uffd-wp marker therefore returns
VM_FAULT_NOPAGE without replacing the marker, causing the fault to repeat
indefinitely.
PAGEMAP_SCAN can also write-protect a DAX PMD, but the huge DAX
write-fault path can make it writable without clearing its uffd-wp bit,
breaking async write tracking.
Device DAX mappings requiring huge-page alignment and cannot serve PTE
faults after UFFDIO_WRITEPROTECT has split their huge mappings.
So let's just disallow DAX mappings in vma_can_userfault() entirely,
making UFFDIO_REGISTER fail with EINVAL.
Link: https://patch.msgid.link/20261118-dax_uffd-v1-1-d776cca1ae17@kernel.org
Fixes: d61ea1cb0095 ("userfaultfd: UFFD_FEATURE_WP_ASYNC")
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Chris Mason <mason@kernel.org>
Reported-by: Jingyi Sun <1045704958@qq.com>
Closes: https://lore.kernel.org/all/tencent_1874C71D4177A1624528043E008DB1A5EF05@qq.com
Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@gmail.com>
Reviewed-by: Gregory Price (Meta) <gourry@gourry.net>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Muhammad Usama Anjum <usama.anjum@arm.com>
mm/userfaultfd.c | 3 +++
1 file changed, 3 insertions(+)
--- a/mm/userfaultfd.c~mm-userfaultfd-reject-dax-mappings
+++ a/mm/userfaultfd.c
@@ -2156,6 +2156,9 @@ static bool vma_can_userfault(struct vm_
/* Only mm-backed memory can have its faults handled by userspace. */
if (!vma_is_mm_backed(vma))
return false;
+ /* DAX fault handlers do not support uffd-wp. */
+ if (vma_is_dax(vma))
+ return false;
/* Core mm may discard droppable memory at any time. */
if (vma_test_single_mask(vma, VMA_DROPPABLE))
return false;
_
Patches currently in -mm which might be from david@kernel.org are
mm-mprotect-dont-skip-uffd-marker-install-when-racing-with-pte-table-reclaim.patch
mm-khugepaged-free-unused-page-table-when-setting-a-huge-pmd-fails.patch
mm-userfaultfd-prevent-poison-marker-loss.patch
mm-hugetlb-compare-against-persistent-count-when-freeing-lowmem-folios.patch
mm-hugetlb-preserve-reservations-when-shrinking-on-highmem.patch
mm-hugetlb-account-temporary-folios-separately.patch
mm-hugetlb-account-temporary-folios-separately-fix.patch
mm-hugetlb-serialize-page-cache-allocations-with-truncation.patch
mm-hugetlb-serialize-page-cache-allocations-with-truncation-fix.patch
mm-memfd-recheck-the-page-cache-before-allocating-a-hugetlb-folio.patch
mm-hugetlb-count-again-if-the-reserve-map-shrank.patch
mm-hugetlb-account-restored-reservations-before-freeing-folios.patch
mm-hugetlb-delay-anon-folio-rmap-removal-until-after-the-tlb-flush.patch
mm-userfaultfd-reject-dax-mappings.patch
^ permalink raw reply [flat|nested] 7+ messages in thread