Re: [PATCH v2 3/3] mm/hugetlb_vmemmap: fix deadlock during PMD split
From: Jose A. Perez de Azpillaga
Date: Wed Nov 11 2026 - 09:58:50 EST
On 11/11/26 10:37 AM, 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/
LGTM:
Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
--
cheers,
jose a. p-a