From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796291056; b=PwkUepCDH9ejT1eLcG4ihtBB30X+oh5OC5wpRBGzaBq67YvAiAVnASEsxzjs5rEjyBqv /xDgCdbGCc0oocA0rVR1ejTWWg3pqse3WRsk8o8PFvPkevVraKjoJeQ+oJsc7adC7GDXt 6el64gbqX7wYZ02gxyMEp8RiaMYlVUrON8DQtDSt9QJuHBq5JFv7R4vC7zIcN2iO6jCGs rCKltF0tuKBBYLaoblTCquyfSxfeY9pXiPOdNJNmKJ+LPhPQD+4jDYhTso3nQIGwgNf1Z okoA/VVH2vaqSH5wt3JWp1/tbiRXy7An7BiIbuxZ3HZP9x9/0FdQbZiWC1aZw/CsOUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291056; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=+0tNEZdFXmVi4pvCJ7z6ZraCZosPHWLKOx82phqeAXk=; b=i1+pUdk+ZxT4I5z7hra4DaktQAlNBkqa5F+MIpkJw+nxpdlaYYDIKL7mmh0iR9/8mCWj bkIoHwensNwqUVL2XGThflj+D2RVBcdjwr3xJqAuStA/EFE5vVtwNaWzoT8fd2urAy/gw i8oFRTlx7NpNDkD7qxaLconAsoC84IOhHyboA61kuXItaTNZDeIpcXVD9wVqeR0pFRxE7 cd6edJyF+kisgcZ9xnINgNwPltdWLZgJqgmO9WNaoA4F+vlmFf3Sloh50nM1kXYxkz3n1 bM6qTG83M2Q5gYdFqQSGjIIyGQsZrO/LvcRrFoAlFQqjMMYWlKZmUpIXQan6gCu78qA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="v/O/whvV"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED2DF606A322 for ; Thu, 3 Dec 2026 09:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=v/O/whvV Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0E6B1F00893; Thu, 3 Dec 2026 09:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796291055; bh=+0tNEZdFXmVi4pvCJ7z6ZraCZosPHWLKOx82phqeAXk=; h=Subject:To:Cc:From:Date; b=v/O/whvVw460n/QOlHeaMwBYMPV83xg5o49jd2Ct4RJUZk/ow5WebjZ4d64rPiKVR /sTKvCd4cAt9+giPv2HbfaYyzQUTD6fxrPD7QwVEfE0tr+Ry4TVI2rKxveEAioVpZk +xqLSIGexEP8HPcc4PAeLIP8QzFSUUcS1r0GAFAE= Subject: FAILED: patch "[PATCH] userfaultfd: clear the inherited uffd bit in move_swap_pte()" failed to apply to 6.12-stable tree To: donggeunyoo.kernel@gmail.com,aarcange@redhat.com,akpm@linux-foundation.org,david@kernel.org,kas@kernel.org,liam@infradead.org,ljs@kernel.org,mhocko@suse.com,peterx@redhat.com,rppt@kernel.org,shuah@kernel.org,stable@vger.kernel.org,surenb@google.com,vbabka@kernel.org Cc: From: Date: Thu, 03 Dec 2026 10:41:34 +0100 Message-ID: <2026120334-tummy-pushup-6056@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x 50abb4245e1ecdd679aef504543bdbc055dc9247 # git commit -s git send-email --to '' --in-reply-to '2026120334-tummy-pushup-6056@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 50abb4245e1ecdd679aef504543bdbc055dc9247 Mon Sep 17 00:00:00 2001 From: Donggeun Yoo Date: Sat, 3 Oct 2026 19:30:29 +0900 Subject: [PATCH] userfaultfd: clear the inherited uffd bit in move_swap_pte() 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//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 Signed-off-by: Andrew Morton Acked-by: David Hildenbrand (Arm) Acked-by: Mike Rapoport (Microsoft) Assisted-by: LLM Cc: Peter Xu Cc: Suren Baghdasaryan Cc: Andrea Arcangeli Cc: Lorenzo Stoakes Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Michal Hocko Cc: Shuah Khan Cc: Kiryl Shutsemau Cc: mm/userfaultfd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 15ad69ec2fc0..65f7399e79b6 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -1403,6 +1403,7 @@ static int move_swap_pte(struct mm_struct *mm, struct vm_area_struct *dst_vma, 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);