[PATCH 32/46] mm/memory_hotplug: avoid races in pfn_to_online_page() with dying pgmap
Gregory Price (Meta)
gourry at gourry.net
Wed Oct 28 14:59:33 PDT 2026
On 2026-10-27 00:17 +0100, David Hildenbrand (Arm) wrote:
> From: Josef Bacik <josef at toxicpanda.com>
>
> If ZONE_DEVICE memory shares a memory section with ordinary memory, the
> section is online and the pfns of the device are valid.
> pfn_to_online_page() tells them apart by asking get_dev_pagemap() whether
> the pfn belongs to a dev_pagemap.
>
> get_dev_pagemap() only returns a dev_pagemap whose reference is alive.
> memunmap_pages() kills the reference first, waits until all pages are
> idle, and then removes the memmap. During all that time the function
> finds nothing, and pfn_to_online_page() hands out the struct pages of the
> device as if they were online memory. A pfn walker reads them while they
> are poisoned and freed.
>
> The entry in pgmap_array is only deleted after the pages have been
> removed. Look at that instead of trying to get a reference.
>
> This is probably not worth CCing stable.
>
> Fix generated by an LLM and sent by Josef Bacik in private.
>
> Fixes: 1f90a3477df3 ("mm: teach pfn_to_online_page() about ZONE_DEVICE section collisions")
> Signed-off-by: Josef Bacik <josef at toxicpanda.com>
> Signed-off-by: David Hildenbrand (Arm) <david at kernel.org>
More zone device pfn-walk brittleness :\
Reviewed-by: Gregory Price (Meta) <gourry at gourry.net>
--
~Gregory
More information about the kexec
mailing list