Re: [PATCH v4 1/4] mm: Introduce vm_uffd_ops API

From: David Hildenbrand

Date: Mon Oct 20 2025 - 10:18:34 EST


On 15.10.25 01:14, Peter Xu wrote:
Currently, most of the userfaultfd features are implemented directly in the
core mm. It will invoke VMA specific functions whenever necessary. So far
it is fine because it almost only interacts with shmem and hugetlbfs.

Introduce a generic userfaultfd API extension for vm_operations_struct,
so that any code that implements vm_operations_struct (including kernel
modules that can be compiled separately from the kernel core) can support
userfaults without modifying the core files.

With this API applied, if a module wants to support userfaultfd, the
module should only need to properly define vm_uffd_ops and hook it to
vm_operations_struct, instead of changing anything in core mm.

This API will not work for anonymous memory. Handling of userfault
operations for anonymous memory remains unchanged in core mm.

Due to a security concern while reviewing older versions of this series
[1], uffd_copy() will be temprorarily removed. IOW, MISSING-capable memory
types can only be hard-coded and implemented in mm/. It would also affect
UFFDIO_COPY and UFFDIO_ZEROPAGE. Other functions should still be able to
be provided from vm_uffd_ops.

Introduces the API only so that existing userfaultfd users can be moved
over without breaking them.

[1] https://lore.kernel.org/all/20250627154655.2085903-1-peterx@xxxxxxxxxx/

Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
---

Acked-by: David Hildenbrand <david@xxxxxxxxxx>

--
Cheers

David / dhildenb