Re: [PATCH v4 3/8] mm/page_alloc: snapshot the preferred zone against shrink rebuilds
From: Vlastimil Babka (SUSE)
Date: Thu Oct 29 2026 - 11:21:55 EST
On 10/28/26 22:19, Gregory Price (Meta) wrote:
> get_page_from_freelist() and alloc_pages_bulk_noprof() reread
> ac->preferred_zoneref->zone at every use. Offlining a zone's last block
> rebuilds the zonelists in place, and the shrunk list's NULL terminator
> can land on the preferred slot mid-walk:
>
> CPU 0 CPU 1
> get_page_from_freelist(GFP_KERNEL | __GFP_THISNODE)
> zone = NORMAL (slot 1)
> offline_pages()
> build_all_zonelists()
> [MOVABLE, NORMAL, NULL]
> -> [NORMAL, NULL]
> rmqueue(zonelist_zone(slot 1), zone)
> zone_statistics(NULL, zone)
>
> BUG: kernel NULL pointer dereference, address: 0000000000000060
> RIP: 0010:get_page_from_freelist+0x6a5/0x15f0
> Call Trace:
> __alloc_frozen_pages_noprof+0x125/0x330
>
> Read the slot once. Zones are never freed, so a stale zone is safe, and
> a NULL slot fails the same way as walking off the end.
>
> Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Gregory Price (Meta) <gourry@xxxxxxxxxx>
Reviewed-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>