5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gregory Price (Meta) commit 9c52ebe9c89d41c56fcb5d94efe9e539414175a9 upstream. Memory hotplug rebuilds zonelists in place while allocations walk them, so a zoneref slot can change between two loads of it. zonelist_zone() loads the slot with a plain access. The compiler may load it again later instead of keeping the zone it already read, so a caller can check one zone and then use another, or the NULL terminator. Use READ_ONCE(). Callers that take a zone from a slot and keep using it, such as get_page_from_freelist() with ac->preferred_zoneref, need that single load. Fixes: 11cd8638c37f ("mm, page_alloc: remove stop_machine from build_all_zonelists") Cc: stable@vger.kernel.org Signed-off-by: Gregory Price (Meta) Link: https://patch.msgid.link/20261101021340.2251928-6-gourry@gourry.net Acked-by: Zi Yan Signed-off-by: Vlastimil Babka (SUSE) Signed-off-by: Greg Kroah-Hartman --- include/linux/mmzone.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1030,7 +1030,8 @@ extern struct zone *next_zone(struct zon static inline struct zone *zonelist_zone(struct zoneref *zoneref) { - return zoneref->zone; + /* Memory hotplug rewrites zonelists in place. */ + return READ_ONCE(zoneref->zone); } static inline int zonelist_zone_idx(struct zoneref *zoneref)