Re: [PATCH v3 3/3] mm/hugetlb_vmemmap: fix deadlock during PMD split

From: Oscar Salvador (SUSE)

Date: Mon Nov 16 2026 - 05:10:33 EST


On Sat, Nov 14, 2026 at 07:25:23PM +0800, Muchun Song wrote:
> vmemmap_remap_range() currently walks vmemmap page tables under
> init_mm.mmap_lock. If the walk reaches a leaf PMD, vmemmap_split_pmd()
> allocates a PTE table with GFP_KERNEL and can enter direct reclaim:
>
> hugetlb_vmemmap_optimize_folio()
> vmemmap_remap_range()
> mmap_read_lock(&init_mm) <-- outer read lock
> ...
> vmemmap_split_pmd()
> pte_alloc_one_kernel(&init_mm) /* GFP_KERNEL */
> <direct reclaim>
> ttm_pool_shrinker_scan()
> ...
> change_page_attr_set_clr()
> mmap_read_lock(&init_mm) <-- self-deadlock
>
> Since commit d5d8b8662e6e ("x86/mm/pat: Acquire init_mm read lock on
> attribute changes to avoid UAF"), reclaim through TTM can enter CPA,
> which also takes init_mm.mmap_lock. If a writer is pending, the nested
> read blocks behind it while the outer read cannot be released, causing a
> self-deadlock.
>
> HVO walks vmemmap ranges whose intermediate page tables remain present.
> vmemmap_split_pmd() revalidates the PMD under init_mm.page_table_lock
> before installing the PTE table. Use the lockless page-table walker so the
> allocation no longer runs under init_mm.mmap_lock.
>
> Fixes: d5d8b8662e6e ("x86/mm/pat: Acquire init_mm read lock on attribute changes to avoid UAF")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://lore.kernel.org/sashiko-outbox-206969@xxxxxxxxxx/
> Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>

Acked-by: Oscar Salvador (SUSE) <osalvador@xxxxxxxxxx>



--
Oscar Salvador
SUSE Labs