Re: [PATCH v1 1/2] userfaultfd: clear the inherited uffd bit in move_swap_pte()
From: Donggeun Yoo
Date: Fri Sep 25 2026 - 00:37:53 EST
On Wed, Sep 23, 2026 at 12:18:30PM +0100, Kiryl Shutsemau wrote:
> Putting it in the 'else' is wrong. Clear uffd on the source
> unconditionally and re-arm based on the target VMA:
>
> orig_src_pte = pte_swp_clear_uffd(orig_src_pte);
> /* Re-arm RWP on the moved swap entry if dst_vma is RWP-registered. */
> if (userfaultfd_rwp(dst_vma))
> orig_src_pte = pte_swp_mkuffd(orig_src_pte);
>
> That is what move_pages_huge_pmd() does with clear_uffd_wp_pmd() before
> its own re-arm, and it is the logically correct way to do this: the
> source's state is gone, the destination decides.
Done in v2:
https://lore.kernel.org/all/20260925042907.2330519-1-donggeunyoo.kernel@xxxxxxxxx/
Thanks,
Donggeun