From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2A073EB81D; Tue, 21 Jul 2026 00:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784594615; cv=none; b=NlWKVEpMFlCDcoBHjylc9yPU+VqolqMeCe23D2H6PfduyGp4Okpsm9EUP9Pp9i06XclTsmfNsUhnDxuqAg7cNWmPVb1WR8L9Nk068VJb3cdC2hUJzs1DvLKqHCmsUfiU8UdWgcPFWal/cuNj0tg7HsovtFTWWyqNNTI3hdOkVns= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784594615; c=relaxed/simple; bh=xfyr9M/BV8Gcrd0YANTwNTQcOEWDIC54xbfs01F+S00=; h=Date:To:From:Subject:Message-Id; b=PCjHOdQeG2pGxNiL90oN9l1ulClPEYBP747HEk9Ob3WIhQn+WXHpdTRg694cQDghYKQ9g4VVmURKpGScSYBhqBhIhaxydBbuNlRYifnyguJ/cEinwL7C8EAIIIxMT3hDh4Nc1SwwYVw7/leVVEHBEeMt4R+VgWaCUHgsQaujyc8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=zFBeXRSo; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="zFBeXRSo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A36711F000E9; Tue, 21 Jul 2026 00:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1784594613; bh=9xog2oM55jO5RBAx0iQ1qGgJlRGKOFWQ+uhs6RR1DIM=; h=Date:To:From:Subject; b=zFBeXRSo7fI9cyKjEtc6kHU4KjWHKwZP9rFaFaZCcD8em+G41iHEKqQspRGa/OUDK b6qGfAP+b2Gkq/T7/4Sg4zJBobYRDHejwbs8JORHA8UKsK11TbiIS/KqipEuFfj4rc L+y0nFBr5xfyVttqIV9LpFTR0emATQoGhxnBCrDw= Date: Mon, 20 Jul 2026 17:43:33 -0700 To: mm-commits@vger.kernel.org,ziy@nvidia.com,ying.huang@linux.alibaba.com,stable@vger.kernel.org,rakie.kim@sk.com,matthew.brost@intel.com,joshua.hahnjy@gmail.com,gourry@gourry.net,david@kernel.org,byungchul@sk.com,balbirs@nvidia.com,apopple@nvidia.com,wangkefeng.wang@huawei.com,akpm@linux-foundation.org From: Andrew Morton Subject: [merged mm-hotfixes-stable] mm-migrate_device-fix-pte_pfn-pte_dirty-called-on-non-present-pte.patch removed from -mm tree Message-Id: <20260721004333.A36711F000E9@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mm: migrate_device: fix pte_pfn/pte_dirty called on non-present PTE has been removed from the -mm tree. Its filename was mm-migrate_device-fix-pte_pfn-pte_dirty-called-on-non-present-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: Kefeng Wang Subject: mm: migrate_device: fix pte_pfn/pte_dirty called on non-present PTE Date: Mon, 6 Jul 2026 19:19:58 +0800 pte_pfn() and pte_dirty() have undefined behaviour when called on a non-present PTE. In migrate_vma_collect_pmd(), these functions may be invoked on non-present entries (e.g., device-private entries), leading to potential crashes from pte_pfn() or incorrect dirty folio accounting from pte_dirty(). Fix both by guarding with pte_present() checks. Link: https://lore.kernel.org/20260708003955.4024340-1-wangkefeng.wang@huawei.com Link: https://lore.kernel.org/20260706111958.3649651-1-wangkefeng.wang@huawei.com Fixes: fd35ca3d12cc ("mm/migrate_device.c: copy pte dirty bit to page") Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive") Signed-off-by: Kefeng Wang Reviewed-by: Balbir Singh Acked-by: Zi Yan Cc: Alistair Popple Cc: Byungchul Park Cc: David Hildenbrand Cc: Gregory Price Cc: "Huang, Ying" Cc: Joshua Hahn Cc: Matthew Brost Cc: Rakie Kim Cc: Ying Huang Cc: Signed-off-by: Andrew Morton --- mm/migrate_device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/mm/migrate_device.c~mm-migrate_device-fix-pte_pfn-pte_dirty-called-on-non-present-pte +++ a/mm/migrate_device.c @@ -401,7 +401,8 @@ again: bool anon_exclusive; pte_t swp_pte; - flush_cache_page(vma, addr, pte_pfn(pte)); + if (pte_present(pte)) + flush_cache_page(vma, addr, pte_pfn(pte)); anon_exclusive = folio_test_anon(folio) && PageAnonExclusive(page); if (anon_exclusive) { @@ -422,7 +423,7 @@ again: migrate->cpages++; /* Set the dirty flag on the folio now the pte is gone. */ - if (pte_dirty(pte)) + if (pte_present(pte) && pte_dirty(pte)) folio_mark_dirty(folio); /* Setup special migration page table entry */ _ Patches currently in -mm which might be from wangkefeng.wang@huawei.com are mm-remove-pagetranscompound.patch mm-mincore-use-walk_page_range_vma-in-do_mincore.patch mm-mprotect-use-walk_page_range_vma-in-mprotect_fixup.patch mm-mlock-use-walk_page_range_vma-in-mlock_vma_pages_range.patch mm-migrate_device-use-walk_page_range_vma-in-migrate_vma_collect.patch mm-introduce-pud_is_huge-helper.patch mm-mincore-remove-special-handling-for-vm_pfnmap.patch mm-mincore-remove-special-handling-for-vm_pfnmap-fix.patch mm-mincore-replace-__get_free_page-with-kmalloc.patch mm-mincore-remove-xa_is_value-in-mincore_swap.patch mm-mincore-improve-mincore_hugetlb.patch mm-mincore-improve-mincore_hugetlb-fix.patch mm-mincore-refactor-mincore_page.patch