[PATCH 2/4] userfaultfd: mark zero pages moved by UFFDIO_MOVE soft-dirty
From: Mike Rapoport (Microsoft)
Date: Wed Dec 02 2026 - 13:20:25 EST
Commit 75cb1cca2c88 ("mm: userfaultfd: correct dirty flags set for both
present and swap pte") made UFFDIO_MOVE set the soft-dirty bit on moved
PTEs, like mremap() does, so that soft-dirty trackers such as CRIU notice
the move.
It missed move_zeropage_pte(), so a zero page moved by UFFDIO_MOVE is not
marked soft-dirty.
Mark the moved zero page PTE soft-dirty as well.
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://sashiko.dev/bug/linux-0c1c66e4-231d-4567-a40c-42243a875a5d
Fixes: eb1521dad8f3 ("userfaultfd: handle zeropage moves by UFFDIO_MOVE")
Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
---
mm/userfaultfd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 772adff8883d3..6c5e5b0c7d784 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1433,6 +1433,8 @@ static int move_zeropage_pte(struct mm_struct *mm,
zero_pte = pte_mkspecial(pfn_pte(zero_pfn(dst_addr),
dst_vma->vm_page_prot));
+ if (pgtable_supports_soft_dirty())
+ zero_pte = pte_mksoft_dirty(zero_pte);
/* Re-arm RWP on the moved PTE if dst_vma is RWP-registered. */
if (userfaultfd_rwp(dst_vma)) {
--
2.53.0