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=1796291053; b=nP9WbHPGf9K6xBwmDnS9ASLYG5YEcknSY0vHRdaA9DM3wg933iIH+a3RNSoiOO5lxUzD oNF1VGSOYVVYuSxRHHYNl+nBO9dCZo6Uk0IBg7rPsgpTYlpK7mu3lbwyXYQ8T6gNI2PVW 63gbwuiqEO9ffjJQ6TjzR5phbSwG21ANo62WogrJbVWu9W9Un7RqyCrcQR4T3+9KiybLi fdov1WqmPh3ocVFmDN+H5ryqNl9v3iY7i3FVI9ei+pGflghAmYA+TLd2iUEs+jqRriipW k4cBXuC9DWG3gyLRr2AV6SOjZJCzNNzhqxLxUslZzlHW8ZteKPG7c6YQq2iMbafuBtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796291053; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=A6qGMz7ZE3HMyVrvV/vzN7cPaqU+6WsHody/dH+3S4s=; b=J8TWwxo1qUHrhSGVxOLW6Ym6VVhtzREsG6LmBd0Jcgdh+MxsgOXd2UBLTjTEqJz39/jx PAg4/k9TQhPipEQlmyvA0meWPRRBuPX/OI3aykogBFVVYnk7iv29oLH7w5E6DnwFvLojR naU6RPa6lgEtm1ycYzBHn5kn/RgdmtSuAJmGsdXLyH+MhOWd8VSRGfCgTiBvlkhnipGKP KVFgzL9kbsJcvX9LrwMGG0iIEFc5T+73Hy5o7TbX4u7f5O2gvFi3tXj3COoUtmpLw2PzP Yyf9C10q0XgGKt/RvV8kGaQuo/Qt9Z3bvOkONMr1DquPcyGZeU1execodiNTGYPYV+Q== 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=1uyeXZk8; 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 14DCA606A32C for ; Thu, 3 Dec 2026 09:44:12 +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=1uyeXZk8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 048161F0089A; Thu, 3 Dec 2026 09:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796291052; bh=A6qGMz7ZE3HMyVrvV/vzN7cPaqU+6WsHody/dH+3S4s=; h=Subject:To:Cc:From:Date; b=1uyeXZk8a/B45s6QCN6CqwrjNBRW0pYitJQpoFqpPTkAvZcLmTFBI9YMgjxxVEIxF ZWmHk3qH8uCq+pmDsMfY/aoYLSvqA5MljsyY6+PJRTV9jPW0gsiBHxzxRb/wL1g9Yk CL3ydfcZZlFcOXYe+kebUWSEhVjcrnkOA7HRFLcU= Subject: FAILED: patch "[PATCH] userfaultfd: clear the inherited uffd bit in move_swap_pte()" failed to apply to 6.18-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:33 +0100 Message-ID: <2026120333-busload-coliseum-52e6@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.18-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.18.y git checkout FETCH_HEAD git cherry-pick -x 50abb4245e1ecdd679aef504543bdbc055dc9247 # git commit -s git send-email --to '' --in-reply-to '2026120333-busload-coliseum-52e6@gregkh' --subject-prefix 'PATCH 6.18.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);