From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41BB32EA469; Tue, 22 Jul 2025 13:54:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753192472; cv=none; b=g44hIvuSWI5HjwCLtd4cDG+ytAm0H5xni9EanjGFdXNtoVc8o3TwjUJEthJdQIEFlECbkJdTNL8VCeEYnheO66f2PchXkNhnKzK5RSExNFxUOh/L6kOEgiFKTlVoe3c8gZguDrIHJZHAJ80Rz72Mml8sMCuUM2p3uicpepGMFdY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753192472; c=relaxed/simple; bh=mef4joxOg/HzGDwf9+hTAWkyzOkFshnp1BgXyOd5Opc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N8RSz8o4e7/SxzTCRpBze791D+8rJcPeuPgVBvEE57JtkndM+2o9QpnrzQRpHYKGGKiutAGnOGeWVcugD2BRlZOVrAburSVVJiDL6cJgmiKH0jQORwHepy6RkL7x0pNJOYK38IOyCPCQzd4LyN6yDNqKxdd04OHbI70ndPEozS4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=a3n+xedV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="a3n+xedV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8989C4CEEB; Tue, 22 Jul 2025 13:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1753192472; bh=mef4joxOg/HzGDwf9+hTAWkyzOkFshnp1BgXyOd5Opc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a3n+xedVfxbd1JD/MzP4wPZ4+XomNALMTT6amS6SG28PmWKZGbpHREF+LDazhlV7V GKWFxSYBgj/oUxKbf1eCAFT/jLlbiaTYHl+Zxi+VHSBeOObzmPAKeekujWnpzcgXCU StrQNz/wrKlk+kBgCeVJ0Mg2CdvprpgwRC25MHK4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zheng Qixing , Christoph Hellwig , Sasha Levin Subject: [PATCH 6.6 068/111] nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list() Date: Tue, 22 Jul 2025 15:44:43 +0200 Message-ID: <20250722134335.912983048@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250722134333.375479548@linuxfoundation.org> References: <20250722134333.375479548@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zheng Qixing [ Upstream commit 80d7762e0a42307ee31b21f090e21349b98c14f6 ] When inserting a namespace into the controller's namespace list, the function uses list_add_rcu() when the namespace is inserted in the middle of the list, but falls back to a regular list_add() when adding at the head of the list. This inconsistency could lead to race conditions during concurrent access, as users might observe a partially updated list. Fix this by consistently using list_add_rcu() in both code paths to ensure proper RCU protection throughout the entire function. Fixes: be647e2c76b2 ("nvme: use srcu for iterating namespace list") Signed-off-by: Zheng Qixing Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 6e2d0fda3ba4a..9feb47a604659 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3596,7 +3596,7 @@ static void nvme_ns_add_to_ctrl_list(struct nvme_ns *ns) return; } } - list_add(&ns->list, &ns->ctrl->namespaces); + list_add_rcu(&ns->list, &ns->ctrl->namespaces); } static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info) -- 2.39.5