* [PATCH] nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list()
@ 2025-07-01 7:17 Zheng Qixing
2025-07-14 13:52 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Zheng Qixing @ 2025-07-01 7:17 UTC (permalink / raw)
To: kbusch, axboe, hch, sagi
Cc: linux-nvme, linux-kernel, yukuai3, yi.zhang, yangerkun, houtao1,
zhengqixing
From: Zheng Qixing <zhengqixing@huawei.com>
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 <zhengqixing@huawei.com>
---
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 e533d791955d..475115edbbe9 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4077,7 +4077,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.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list()
2025-07-01 7:17 [PATCH] nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list() Zheng Qixing
@ 2025-07-14 13:52 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2025-07-14 13:52 UTC (permalink / raw)
To: Zheng Qixing
Cc: kbusch, axboe, hch, sagi, linux-nvme, linux-kernel, yukuai3,
yi.zhang, yangerkun, houtao1, zhengqixing
Thanks, applied to nvme-6.16.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-14 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-01 7:17 [PATCH] nvme: fix inconsistent RCU list manipulation in nvme_ns_add_to_ctrl_list() Zheng Qixing
2025-07-14 13:52 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).