Re: [PATCH v1] mm/userfaultfd: propagate uffd-wp bit when PTE-mapping the huge zeropage

Andrew Morton
2023-03-03T01:57:39Z

On Thu, 2 Mar 2023 18:54:23 +0100 David Hildenbrand <david@redhat.com> wrote:

> Currently, we'd lose the userfaultfd-wp marker when PTE-mapping a huge
> zeropage, resulting in the next write faults in the PMD range
> not triggering uffd-wp events.
>
> Various actions (partial MADV_DONTNEED, partial mremap, partial munmap,
> partial mprotect) could trigger this. However, most importantly,
> un-protecting a single sub-page from the userfaultfd-wp handler when
> processing a uffd-wp event will PTE-map the shared huge zeropage and
> lose the uffd-wp bit for the remainder of the PMD.
>
> Let's properly propagate the uffd-wp bit to the PMDs.
>
> ...
>
> Fixes: e06f1e1dd499 ("userfaultfd: wp: enabled write protection in userfaultfd API")
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Jerome Glisse <jglisse@redhat.com>
> Cc: Shaohua Li <shli@fb.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>

Do you agree that a -stable backport is appropriate?