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=1796324403; b=uzb0/Mjn9Et4Qh730bpRQAR8dvoTUQmTiiiJwdkXQGMNLu1BabSG0Q7BMOXlp5tp6vyP l3jOR2PHhzzgV2/VNDSOItLmTfxZLYhIjdND6YyJN7ekSvSCZhaQ95sJ/V+/imLx6fWO2 xiFk/A53hWUlrP7zsSt0tdLTWM1M0gZWdLnpsyLa6ZZeU8gzOJPTCbbGOlwU9bxKVMACp xCaxdXscMzvzerurK67uNmYknLK2EMqoI8LmtQJd7RA9sbAFaw+NsBh8w63W/Y7Bucn3H fQ8wVny8MdEwvDQnLCVbEuJxQMNmXMuIq9vWLRT454nM7Gm9e3/2BeFfkQKeiRbUj0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796324403; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=UkcPaWA3HR/1rXZxNVU992oOQ0stxMuHjtR0DCuRq/I=; b=R+n64BcIMhhcpqyU4RRPOqOtqMnq8sD9sOHEDRxi0EjN9dJZixXbON2MipGoLwilXrlG 1IwuQRhX54v0lbsXdh1E3cgt1K5eVFStDTGfbtm7K9o36CvSbRH2WFwbyGWB2Re7YZ28n zkuEh8i4VuiHVDHwSvSB+aFA2uHPj6XP/Mcl5I42xB2CV9lNwEWKdmT7mZCjISWZ4jDIK KcwjZR/SqeagnKG4VuqKg7BLkX5bTXKkjOxqrBGyV4sBnnCRZWNTFM/ke2QTf3wAlScOc +1sU5dbKdfLhgj9qSZV5TGNnClwfpsjgl0lJplOjZlUERG1Dcw9vMnFq9EZW9a4B3Gw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=hh5P2FSY; 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 76844606A32D for ; Thu, 3 Dec 2026 19:00:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=hh5P2FSY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E6C1F000C1; Thu, 3 Dec 2026 19:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796324403; bh=UkcPaWA3HR/1rXZxNVU992oOQ0stxMuHjtR0DCuRq/I=; h=Date:To:From:In-Reply-To:References:Subject; b=hh5P2FSYKDghs7brUmNX4tlbblbozrlkEgDc9RB3ULfSlWPHrIFAgE/XdzP+4a/pc E2hn50vDXlgMcWU/s28VJCaSw8mOfs2wDog4pLh/biRji73hbFiOLtoiirm3vt9TVM GawLehfcYKQRDc5zCHerp5kcFyrizj9dIHYD0xHQ= Date: Thu, 03 Dec 2026 11:00:02 -0800 To: mm-commits@vger.kernel.org,david@kernel.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261125-hugetlb_fixes_2-v1-11-db27fd2f71a8@kernel.org> References: <20261125-hugetlb_fixes_2-v1-11-db27fd2f71a8@kernel.org> Subject: [to-be-updated] mm-migrate-check-hugetlb-pmd-sharing-in-move_pages.patch removed from -mm tree Message-Id: <20261203190003.00E6C1F000C1@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The quilt patch titled Subject: mm/migrate: check hugetlb PMD sharing in move_pages() has been removed from the -mm tree. Its filename was mm-migrate-check-hugetlb-pmd-sharing-in-move_pages.patch This patch was dropped because an updated version will be issued ------------------------------------------------------ From: "David Hildenbrand (Arm)" Subject: mm/migrate: check hugetlb PMD sharing in move_pages() Date: Wed, 25 Nov 2026 23:33:09 +0100 Without MPOL_MF_MOVE_ALL, which requires CAP_SYS_NICE, move_pages(2) refuses to migrate folios that might be mapped by other processes. However, folio_maybe_mapped_shared() does not check for page table sharing. So move_pages(2) with MPOL_MF_MOVE can migrate hugetlb folios that other processes map. mbind(2) and migrate_pages(2) already handle PMD table sharing since commit 73bdf65ea748 ("migrate: hugetlb: check for hugetlb shared PMD in node migration"), but we missed move_pages(2). Let's fix it by using hugetlb_folio_maybe_mapped_shared() for hugetlb folios in move_pages(2). Such folios are now reported with -EACCES in the status array. Rework the code to have separate checks for hugetlb vs. !hugetlb. This has low urgency. Link: https://patch.msgid.link/20261125-hugetlb_fixes_2-v1-11-db27fd2f71a8@kernel.org Fixes: e632a938d914 ("mm: migrate: add hugepage migration code to move_pages()") Signed-off-by: David Hildenbrand (Arm) Signed-off-by: Andrew Morton Reported-by: Chris Mason Cc: Muchun Song Cc: Oscar Salvador Cc: Jinmeng Zhou Cc: Hongfu Li Cc: Andrea Arcangeli Cc: Naoya Horiguchi Cc: Hugh Dickins Cc: Baolin Wang Cc: Dave Airlie Cc: Vivek Kasireddy Cc: Gerd Hoffmann Cc: Mike Rapoport Cc: Mel Gorman Cc: Dave McCracken Cc: Andy Whitcroft Cc: Adam Litke Cc: Lorenzo Stoakes Cc: Rik van Riel Cc: Liam R. Howlett Cc: Vlastimil Babka Cc: Harry Yoo Cc: Jann Horn Cc: Lance Yang Cc: James Houghton Cc: Yang Shi Cc: Suren Baghdasaryan Cc: Shakeel Butt Cc: Pedro Falcato Cc: Gregory Price Cc: Zi Yan Cc: Joshua Hahn Cc: Rakie Kim Cc: Ying Huang Cc: Matthew Brost Cc: Byungchul Park Cc: Alistair Popple Cc: Wanpeng Li Cc: Andi Kleen Cc: Kenneth W Chen Cc: Michal Hocko Cc: David Rientjes Cc: Joern Engel Cc: Jonathan Corbet Cc: Shuah Khan Cc: Randy Dunlap Cc: Aneesh Kumar K.V Cc: KAMEZAWA Hiroyuki Cc: Kiryl Shutsemau Cc: Sasha Levin Cc: Guillaume Morin Cc: Jason Gunthorpe Cc: luojiajun Cc: Josef Bacik Cc: Daehyeon Ko <4ncienth@gmail.com> Cc: Ackerley Tng Cc: Jiaqi Yan Cc: mm/migrate.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/mm/migrate.c~mm-migrate-check-hugetlb-pmd-sharing-in-move_pages +++ a/mm/migrate.c @@ -2340,8 +2340,9 @@ static int do_move_pages_to_node(struct return err; } -static int __add_folio_for_migration(struct folio *folio, int node, - struct list_head *pagelist, bool migrate_all) +static int __add_folio_for_migration(struct folio *folio, + struct folio_walk *fw, int node, struct list_head *pagelist, + bool migrate_all) { if (is_zero_folio(folio) || is_huge_zero_folio(folio)) return -EFAULT; @@ -2352,13 +2353,19 @@ static int __add_folio_for_migration(str if (folio_nid(folio) == node) return 0; - if (folio_maybe_mapped_shared(folio) && !migrate_all) - return -EACCES; - if (folio_test_hugetlb(folio)) { + /* fw->ptep aliases fw->pmdp and fw->pudp. */ + if (!migrate_all && hugetlb_folio_maybe_mapped_shared(folio, fw->ptep)) + return -EACCES; if (folio_isolate_hugetlb(folio, pagelist)) return 1; - } else if (folio_isolate_lru(folio)) { + return -EBUSY; + } + + if (!migrate_all && folio_maybe_mapped_shared(folio)) + return -EACCES; + + if (folio_isolate_lru(folio)) { list_add_tail(&folio->lru, pagelist); node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio), @@ -2393,8 +2400,8 @@ static int add_folio_for_migration(struc if (vma && vma_migratable(vma)) { folio = folio_walk_start(&fw, vma, addr, FW_ZEROPAGE); if (folio) { - err = __add_folio_for_migration(folio, node, pagelist, - migrate_all); + err = __add_folio_for_migration(folio, &fw, node, + pagelist, migrate_all); folio_walk_end(&fw, vma); } else { err = -ENOENT; _ Patches currently in -mm which might be from david@kernel.org are mm-mprotect-dont-skip-uffd-marker-install-when-racing-with-pte-table-reclaim.patch mm-userfaultfd-prevent-poison-marker-loss.patch mm-hugetlb-compare-against-persistent-count-when-freeing-lowmem-folios.patch mm-hugetlb-preserve-reservations-when-shrinking-on-highmem.patch mm-hugetlb-account-temporary-folios-separately.patch mm-hugetlb-account-temporary-folios-separately-fix.patch mm-hugetlb-serialize-page-cache-allocations-with-truncation.patch mm-hugetlb-serialize-page-cache-allocations-with-truncation-fix.patch mm-memfd-recheck-the-page-cache-before-allocating-a-hugetlb-folio.patch mm-hugetlb-count-again-if-the-reserve-map-shrank.patch mm-hugetlb-account-restored-reservations-before-freeing-folios.patch mm-hugetlb-delay-anon-folio-rmap-removal-until-after-the-tlb-flush.patch mm-userfaultfd-reject-dax-mappings.patch mm-filemap-avoid-retrying-faults-on-uffd-wp-markers.patch mm-hugetlb-dont-share-page-tables-of-a-vma-during-mprotect.patch mm-hugetlb-count-migration-entries-at-fork-and-unmap.patch mm-hugetlb-stop-accounting-hugetlbpages-once-pmd-tables-were-shared.patch fs-proc-task_mmu-dont-clear-vm_softdirty-on-hugetlb-vmas.patch rfc-mm-hugetlb_cgroup-charge-faults-to-mm-owner.patch a.patch