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 3E1773DE422 for ; Tue, 30 Jun 2026 19:51:08 +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=1782849069; cv=none; b=EiQXoXRoPnCdhAWMeQOQ5/k6y0yTWohO006JM3PLVGn1qtO4cILLvaNhqCuk7D97qg/jLNYtVLPhAvugP79cvbFVCeu9swIoP8l3enO55ZEa9LhigHWaO3J4TeQInTPDCdp+dys+qnZ4UEyE2VG/MKnSmhFb4DWbp/9Yn3a1CZ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782849069; c=relaxed/simple; bh=sQVfCpqvHZPwvpNkBOzU+FTVtUAFws//O9FdLefkriQ=; h=Date:To:From:Subject:Message-Id; b=L9E8W9XRIO0LYPo6Nly6YLwtZxY2L9HimQHl/LRS1+w5REuE9mDojj8BHtOvMAITbnWZjpGmNXkuPXbrBqgRTWINUsVrFPSWkNEhWn3i+LqHkJ/o+KGnfeQEs6jEes2w1b5JV91H8vODeIAxyYTO239qxV51Bzk6D+aUndQvKRk= 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=aA7sy0IE; 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="aA7sy0IE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC8F21F00A3A; Tue, 30 Jun 2026 19:51:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1782849067; bh=mKxwd7Fzn3uHUDFOsBgtlp2/RgyiyQ9q9peVBOhX00c=; h=Date:To:From:Subject; b=aA7sy0IE33XolvOD0/qtyM6qEDSMWXbS8Mm5mIzhU/0dT8YNwD8vAn6XGpl+tDlcN 4HsFkpOQqrAwGhIfvrM2qgxtU2USKhq/iMWwFVNCTANoIcG2VFkJ8a+7mzp759IaCF po+11lZ/woYt7K1FW7iN8Y1uE/3zi/ROu2izrfpM= Date: Tue, 30 Jun 2026 12:51:07 -0700 To: mm-commits@vger.kernel.org,usama.arif@linux.dev,akpm@linux-foundation.org From: Andrew Morton Subject: + mm-migrate_device-move-softleaf_to_folio-inside-device-private-branch.patch added to mm-new branch Message-Id: <20260630195107.CC8F21F00A3A@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: mm/migrate_device: move softleaf_to_folio() inside device-private branch has been added to the -mm mm-new branch. Its filename is mm-migrate_device-move-softleaf_to_folio-inside-device-private-branch.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-migrate_device-move-softleaf_to_folio-inside-device-private-branch.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Usama Arif Subject: mm/migrate_device: move softleaf_to_folio() inside device-private branch Date: Tue, 30 Jun 2026 09:34:42 -0700 migrate_vma_collect_pmd() calls softleaf_to_folio() on a non-present PMD before checking the entry's type. softleaf_to_folio() converts the entry's offset to a PFN, which is only meaningful for migration or device-private entries. A PMD swap entry's offset is a swap offset, not a PFN, so the lookup would either return a bogus folio pointer or trip pfn_to_page validation on a debug kernel. In the non-device-private path the returned folio is then unused (the OR short-circuits to migrate_vma_collect_skip()), but the lookup itself is already unsafe. Move the softleaf_to_folio() call inside the device-private branch where the folio is actually needed, mirroring the equivalent change_non_present_huge_pmd() fix. Link: https://lore.kernel.org/20260630164143.1595669-6-usama.arif@linux.dev Signed-off-by: Usama Arif Reviewed-by: Zi Yan Cc: Alexandre Ghiti Cc: Baolin Wang Cc: Baoquan He Cc: Barry Song Cc: Chris Li Cc: David Hildenbrand (Arm) Cc: Dev Jain Cc: "Huang, Ying" Cc: Johannes Weiner Cc: Kairui Song Cc: Kemeng Shi Cc: Kiryl Shutsemau Cc: Lance Yang Cc: Liam R. Howlett Cc: Lorenzo Stoakes Cc: Matthew Wilcox (Oracle) Cc: Nhat Pham Cc: Nico Pache Cc: Rik van Riel Cc: Ryan Roberts Cc: Shakeel Butt Cc: Vlastimil Babka Signed-off-by: Andrew Morton --- mm/migrate_device.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/mm/migrate_device.c~mm-migrate_device-move-softleaf_to_folio-inside-device-private-branch +++ a/mm/migrate_device.c @@ -166,11 +166,14 @@ static int migrate_vma_collect_huge_pmd( } else if (!pmd_present(*pmdp)) { const softleaf_t entry = softleaf_from_pmd(*pmdp); - folio = softleaf_to_folio(entry); - if (!softleaf_is_device_private(entry) || - !(migrate->flags & MIGRATE_VMA_SELECT_DEVICE_PRIVATE) || - (folio->pgmap->owner != migrate->pgmap_owner)) { + !(migrate->flags & MIGRATE_VMA_SELECT_DEVICE_PRIVATE)) { + spin_unlock(ptl); + return migrate_vma_collect_skip(start, end, walk); + } + + folio = softleaf_to_folio(entry); + if (folio->pgmap->owner != migrate->pgmap_owner) { spin_unlock(ptl); return migrate_vma_collect_skip(start, end, walk); } _ Patches currently in -mm which might be from usama.arif@linux.dev are mm-swap_state-remove-unnecessary-lru_add_drain-from-readahead.patch mm-vmpressure-skip-tree=true-accounting-on-cgroup-v2.patch mm-vmpressure-split-v1-userspace-eventfd-code-into-vmpressure-v1c.patch mm-add-softleaf_to_pmd-and-convert-existing-callers.patch mm-extract-mm_prepare_for_swap_entries-helper.patch fs-proc-use-softleaf_has_pfn-in-pagemap-pmd-walker.patch mm-huge_memory-move-softleaf_to_folio-inside-migration-branch.patch mm-migrate_device-move-softleaf_to_folio-inside-device-private-branch.patch mm-rename-arch_enable_thp_migration-to-arch_supports_pmd_softleaf.patch