* [PATCH] nvmet-tcp: fix NULL pointer dereference in nvmet_execute_identify_nslist()
[not found] <2026081423-enlarged-dribble-10bb@gregkh>
@ 2026-08-14 19:00 ` Shivam Kumar
2026-08-17 6:58 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Shivam Kumar @ 2026-08-14 19:00 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: security, hch, sagi, kch, linux-nvme, kumar.shivam43666, stable
nvmet_execute_identify_nslist() handles the I/O Command Set Active
Namespace ID List (CNS 07h) with match_css set. The per-namespace
filter in the iteration loop tests req->ns->csi, but req->ns is NULL
for this command: nvmet_req_init() clears req->ns for every request,
and CNS 07h uses the NSID field only as a starting filter (min_nsid),
so no namespace is ever looked up. The intended value is the loop
variable ns->csi.
A remote host that sends an Identify command with CNS 07h to a
subsystem with at least one enabled namespace dereferences the NULL
req->ns (at offsetof(struct nvmet_ns, csi)) and crashes the target.
Use the loop variable ns instead.
Fixes: 61c9967cd634 ("nvmet: implement active command set ns list")
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Shivam Kumar <kumar.shivam43666@gmail.com>
Cc: stable@vger.kernel.org
---
drivers/nvme/target/admin-cmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 01b799e92ae6..ab6a0a98dd5d 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -958,7 +958,7 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req, bool match_css)
nvmet_for_each_enabled_ns(&ctrl->subsys->namespaces, idx, ns) {
if (ns->nsid <= min_nsid)
continue;
- if (match_css && req->ns->csi != req->cmd->identify.csi)
+ if (match_css && ns->csi != req->cmd->identify.csi)
continue;
list[i++] = cpu_to_le32(ns->nsid);
if (i == buf_size / sizeof(__le32))
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread