Re: [PATCH 14/32] mm/huge_memory: split huge zero PMDs on unshare faults
From: Jose A. Perez de Azpillaga
Date: Sun Nov 29 2026 - 15:33:12 EST
On 11/29/26 11:06 AM, 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>
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a