[PATCH 0/2] mm/userfaultfd: prevent poison marker loss

From: David Hildenbrand (Arm)

Date: Fri Nov 06 2026 - 18:51:51 EST


Now that Lorenzo's atomic vma flag fixes are in, we can also use it
for userfaultfd POISON markers.

In patch #1, we use a new VM_MAYBE_UFFD_POISON to remember that we had
POISON markers installed by uffd. We then use that to fix marker
handling during fork(), during hugetlb PMD table sharing, and during
retract_page_tables().

In patch #2, we perform a similar rework to retract_page_tables()[1] that
we did to try_collapse_pte_mapped_thp(), to make the code simpler and
less error-prone.

Once review finished, I will take this through core.git, where it
depends on a related try_collapse_pte_mapped_thp() cleanup/fix.

This is not urgent, just something that should be fixed properly.

[1] https://lore.kernel.org/linux-mm/20261031-fixes_core-v3-18-d6437171ecc3@xxxxxxxxxx/

Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
---
David Hildenbrand (Arm) (2):
mm/userfaultfd: prevent poison marker loss
mm/khugepaged: check for empty PTE tables before retracting

Documentation/filesystems/proc.rst | 1 +
fs/proc/task_mmu.c | 3 +
include/linux/mm.h | 45 ++++++++-----
include/linux/userfaultfd_k.h | 7 ++-
include/trace/events/mmflags.h | 9 ++-
mm/Kconfig | 1 +
mm/khugepaged.c | 126 +++++++++++++------------------------
mm/userfaultfd.c | 3 +
tools/testing/vma/include/dup.h | 20 ++++--
9 files changed, 110 insertions(+), 105 deletions(-)

---

base-commit: df3c65887715e66e2cba69116924020c37996cd8

change-id: 20261106-b4-uffd_marker_loss-f0f56ec12ce6

--

Cheers,

David