From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388094; b=aZablRp80uCAG6zZhCuNNYbLZgig8VLIPpSlntyc9sYGK/zDt47lXIuUafwZ759EA6eA 6RWRSG7zTdEUrDXI+yFofdrczUt2buDMb9YwO+kf+bZIZ1LmGD+SNg64IdAt22XXS5MIq Iab3jNgwoPD7Tj9LPqr3mwQGm8T6jbzGUpELVgo1iwATacs8RO+2ilutAdzJQZ4hEc60x dvDSpwAbFRTcmDpd+f0ia1ZG711a+EjI3/QJp58Ia9UB5TufWOqS7/IeSbAZd2kuml9oC Pm9qVnehRJPlXGzB5lBRE1+KjNFjBgMN8eYH5IXR1hKOAyr3xVG0tUCIaSYOwKgREkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388094; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=WJNnHO9sp/nBr1rH9jiLJylVzkJcTwman/5zk6pVp+Q=; b=S9GXybRdvDaVRO5A+XScSPmoZlgfSvCOXbJcuoLPmbKFEjIC4VPKvYYo45o+LYhdZdJ6 2Ux/E1gZsUqFo0foAaeodOFhUz68MjN564hK8DxevveSHlhiR4LftosmrNVjjlYrsA26D yHPIq0BFCu9b4prA7Rw8hP8cPtepaY7NQcj74wB53ThagrMu6Xs8v9uTkS53TxJrnUpYV DwFRVLQ3YU9ySsLvGv/3pvmbqskZkbMbFL9HsloDSKsoEhZDqPbCvE2PRofS3ruEHmgB8 tJ2d50GI8+nF5d00IWOuW1vZmlyypXtxduW0B4PqkTv5NMpfDdXYt1JAGkCl5u6KsAw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=p6Jp9KIJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 357DE606A32D; Fri, 4 Dec 2026 12:41:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=p6Jp9KIJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FA821F000CE; Fri, 4 Dec 2026 12:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388094; bh=WJNnHO9sp/nBr1rH9jiLJylVzkJcTwman/5zk6pVp+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=p6Jp9KIJ0Znk6k4Cg5ysdcSQAEI7iE6xL6zNSd+8LMzU2CIT58MxAvdUMeb8pcJax qzQLM7ESZ5xZJeREOu8E1pVMLmbpNzAd/Sxl2j0URoNck1upOlRNbr13EOaG0zS9F8 EiUWr5zIgWSpkFpcr4pJ7JJISN4lalyRSwRjPBk4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Gregory Price (Meta)" , Zi Yan , "Vlastimil Babka (SUSE)" Subject: [PATCH 6.1 0480/1059] mm/mmzone: read the zoneref slot once in zonelist_zone() Date: Fri, 4 Dec 2026 19:00:11 +0900 Message-ID: <20261204100656.679449145@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 @@ -1439,7 +1439,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)