Re: [PATCH v3 1/3] mm/hugetlb_vmemmap: fix HWPoison state races during optimization
From: Oscar Salvador (SUSE)
Date: Mon Nov 16 2026 - 04:02:29 EST
On Sat, Nov 14, 2026 at 07:25:21PM +0800, Muchun Song wrote:
> HVO copies the vmemmap head page before remapping it to a newly allocated
> backing page. Memory failure can update the old head page after the copy
> but before the remap's TLB invalidation completes:
>
> CPU 0 CPU 1
> init_new_hugetlb_folio()
> __hugetlb_vmemmap_optimize_folio()
> vmemmap_optimize_pte()
> copy_page(old_head, new_head)
> try_memory_failure_hugetlb()
> get_huge_page_for_hwpoison()
> hugetlb_update_hwpoison(old_head)
> set_pte_at(..., new_head)
> flush_tlb_all()
> free_vmemmap_page_list(old_head)
>
> The raw_hwp_page linked to the old head is then leaked and the folio's
> HWPoison state is lost when the obsolete backing page is freed, allowing
> the poisoned huge page to be allocated later.
>
> Unpoisoning has a similar race: unpoison_memory() can free the
> raw_hwp_page and clear PG_hwpoison from the old head after it is copied,
> leaving the new head with stale HWPoison state and a freed pointer.
>
> Serialize HVO remapping against HWPoison updates and removal. This
> ensures that an update is either copied to the new vmemmap head page or
> applied after HVO installs the new mapping and completes the TLB flush,
> and prevents unpoisoning from modifying the old head while HVO installs
> its replacement.
>
> Fixes: 11aad2631bf7 ("mm/hugetlb_vmemmap: remap head page to newly allocated page")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Muchun Song <songmuchun@xxxxxxxxxxxxx>
> Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> Closes: https://sashiko.dev/#/bug/linux-18e93f17-529b-4d84-ba44-a41829f4be64
> Reviewed-by: Jiaqi Yan <jiaqiyan@xxxxxxxxxx>
> Reviewed-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
Acked-by: Oscar Salvador (SUSE) <osalvador@xxxxxxxxxx>
--
Oscar Salvador
SUSE Labs