userfaultfd-gate-must_wait-writability-check-on-pte_present.patch removed from -mm tree
The quilt patch titled
Subject: userfaultfd: gate must_wait writability check on pte_present()
has been removed from the -mm tree. Its filename was
userfaultfd-gate-must_wait-writability-check-on-pte_present.patch
This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: "Kiryl Shutsemau (Meta)" <[email protected]>
Subject: userfaultfd: gate must_wait writability check on pte_present()
Date: Fri, 29 May 2026 18:23:29 +0100
userfaultfd_must_wait() and userfaultfd_huge_must_wait() read the PTE without taking the page table lock and then apply pte_write() / huge_pte_write() to it. Those accessors decode bits from the present encoding only; on a swap or migration entry they read the offset bits that happen to share the same position and return an undefined result.
The intent of the check is "is this fault still WP-blocked?". A non-marker swap entry means the page is in transit -- the userfault context the original fault delivered against is no longer the same, and the swap-in or migration completion path will re-deliver a fresh fault if userspace still needs to handle it. Worst case under the current code the garbage write bit says "wait", and the thread stays asleep until a UFFDIO_WAKE that may never arrive.
Gate the writability check on pte_present() so the lockless re-check only inspects present-PTE bits when the entry is actually present. The non-present, non-marker case returns "don't wait" and lets the fault path retry.
---
mm/userfaultfd.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
mm/userfaultfd.c renamed from mm/userfaultfd.c~userfaultfd-gate-must_wait-writability-check-on-pte_present +20 -0
@@ -2543,6 +2543,15 @@ static inline bool userfaultfd_huge_mustif (pte_is_uffd_marker (pte))return true;/* +* Concurrent migration may have replaced the present PTE with a +* non-marker swap entry between fault delivery and this lockless +* re-check. huge_pte_write() on a swap entry decodes random offset +* bits, so gate it on pte_present(). The migration completion path +* will re-deliver the fault if it still needs userspace. +*/ +if (!pte_present (pte)) +return false; +/* * If VMA has UFFD WP faults enabled and WP fault, wait for userspace to * resolve the fault. */
@@ -2629,6 +2638,17 @@ again:if (pte_is_uffd_marker (ptent)) goto out;/* +* Concurrent swap-out / migration may have replaced the present PTE +* with a non-marker swap entry between fault delivery and this +* lockless re-check. pte_write() on a swap entry decodes random +* offset bits, so gate it on pte_present(). The page-in path will +* re-deliver the fault if it still needs userspace. +*/ +if (!pte_present (ptent)) { + ret = false; + goto out; + } +/* * If VMA has UFFD WP faults enabled and WP fault, wait for userspace to * resolve the fault. */
_
Patches currently in -mm which might be from [email protected] are