From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,vbabka@kernel.org,surenb@google.com,
stable@vger.kernel.org,shuah@kernel.org,rppt@kernel.org,peterx@redhat.com,
mhocko@suse.com,ljs@kernel.org,liam@infradead.org,kas@kernel.org,
david@kernel.org,aarcange@redhat.com,donggeunyoo.kernel@gmail.com,
akpm@linux-foundation.org
Subject: [merged mm-hotfixes-stable] userfaultfd-clear-the-inherited-uffd-bit-in-move_swap_pte.patch removed from -mm tree
Date: Sun, 22 Nov 2026 22:25:17 -0800 [thread overview]
Message-ID: <20261123062517.A05F41F000CF@smtp.kernel.org> (raw)
The quilt patch titled
Subject: userfaultfd: clear the inherited uffd bit in move_swap_pte()
has been removed from the -mm tree. Its filename was
userfaultfd-clear-the-inherited-uffd-bit-in-move_swap_pte.patch
This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Subject: userfaultfd: clear the inherited uffd bit in move_swap_pte()
Date: Sat, 3 Oct 2026 19:30:29 +0900
UFFDIO_MOVE on a swapped-out page installs the source PTE at the
destination unchanged, so a uffd bit set on a write-protected or
RWP-protected source lands in a destination VMA that was never
registered for either. Nothing clears it there, and userspace sees:
- /proc/<pid>/pagemap reports the page as uffd-tracked (bit 57), both
while it is swapped out and after it is faulted back in.
- MADV_COLLAPSE fails with EINVAL on a range containing it, because the
collapse scan bails on a swap entry with the uffd bit set.
- With CONFIG_PAGE_TABLE_CHECK, faulting the page in warns.
do_swap_page() carries the bit into the present PTE and, since the
destination isn't WP-registered, also makes it writable:
WARNING: mm/page_table_check.c:202 at __page_table_check_ptes_set+0x185/0x1e0
Call Trace:
set_ptes+0x67/0xc0
do_swap_page+0x990/0xfe0
__handle_mm_fault+0x7d0/0xeb0
handle_mm_fault+0x9c/0x250
do_user_addr_fault+0x207/0x650
exc_page_fault+0x65/0x150
asm_exc_page_fault+0x26/0x30
Reaching it takes UFFDIO_MOVE out of a WP- or RWP-protected area into
one that isn't, on a page that is swapped out at the time. It hasn't
been seen in practice.
A resident page doesn't carry the bit, because move_present_ptes() builds
the destination PTE from dst_vma->vm_page_prot. Clear it on the moved
swap entry as well, then re-arm it if the destination is RWP-registered.
The WP case has been there since v6.8, where UFFDIO_MOVE was added.
Link: https://lore.kernel.org/20261003103030.63380-1-donggeunyoo.kernel@gmail.com
Link: https://lore.kernel.org/20261003103030.63380-2-donggeunyoo.kernel@gmail.com
Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Assisted-by: LLM
Cc: Peter Xu <peterx@redhat.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Kiryl Shutsemau <kas@kernel.org>
Cc: <stable@vger.kernel.org>
mm/userfaultfd.c | 1 +
1 file changed, 1 insertion(+)
--- a/mm/userfaultfd.c~userfaultfd-clear-the-inherited-uffd-bit-in-move_swap_pte
+++ a/mm/userfaultfd.c
@@ -1403,6 +1403,7 @@ static int move_swap_pte(struct mm_struc
orig_src_pte = ptep_get_and_clear(mm, src_addr, src_pte);
if (pgtable_supports_soft_dirty())
orig_src_pte = pte_swp_mksoft_dirty(orig_src_pte);
+ 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);
_
Patches currently in -mm which might be from donggeunyoo.kernel@gmail.com are
selftests-mm-add-tests-for-uffdio_move-of-a-uffd-protected-swap-entry.patch
reply other threads:[~2026-11-23 6:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123062517.A05F41F000CF@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=aarcange@redhat.com \
--cc=david@kernel.org \
--cc=donggeunyoo.kernel@gmail.com \
--cc=kas@kernel.org \
--cc=liam@infradead.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=mm-commits@vger.kernel.org \
--cc=peterx@redhat.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox