Re: [PATCH 14/32] mm/huge_memory: split huge zero PMDs on unshare faults
From: Zi Yan
Date: Tue Dec 01 2026 - 20:17:22 EST
On Sun Nov 29, 2026 at 5:06 AM EST, David Hildenbrand (Arm) wrote:
> FAULT_FLAG_UNSHARE breaks COW without making the mapping writable.
> Unlike FAULT_FLAG_WRITE, it must leave write protection in place so
> that a later write still faults.
>
> A read-only long-term pin can trigger an unshare fault on a huge zero
> PMD. do_huge_zero_wp_pmd() treats it as a write fault: it marks the
> replacement THP dirty, makes it writable if the VMA allows writes, and
> drops any UFFD write protection.
>
> Consequently, a later write no longer faults, which, for example,
> bypasses UFFD write protection.
>
> Let's fix it by returning VM_FAULT_FALLBACK for unshare faults, so the
> caller splits the PMD. The PTE fault path already handles unsharing
> while keeping the mapping read-only and preserving UFFD write protection
> and soft-dirty state.
>
> This has low urgency, as it requires a read-only long-term pin of a huge
> zero PMD. No need to CC stable.
>
> Fixes: 1ced09e0331f ("mm: allocate THP on hugezeropage wp-fault")
> Reported-by: Chris Mason <mason@xxxxxxxxxx>
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> ---
> mm/huge_memory.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
LGTM.
Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>
--
Best Regards,
Yan, Zi