Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Shivam Kumar <kumar.shivam43666@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: security@kernel.org, hch@lst.de, sagi@grimberg.me,
	kch@nvidia.com, linux-nvme@lists.infradead.org,
	kumar.shivam43666@gmail.com, stable@vger.kernel.org
Subject: [PATCH] nvmet-tcp: fix NULL pointer dereference in nvmet_execute_identify_nslist()
Date: Fri, 14 Aug 2026 15:00:22 -0400	[thread overview]
Message-ID: <20260814190022.1531236-1-kumar.shivam43666@gmail.com> (raw)
In-Reply-To: <2026081423-enlarged-dribble-10bb@gregkh>

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



       reply	other threads:[~2026-08-14 19:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2026081423-enlarged-dribble-10bb@gregkh>
2026-08-14 19:00 ` Shivam Kumar [this message]
2026-08-17  6:58   ` [PATCH] nvmet-tcp: fix NULL pointer dereference in nvmet_execute_identify_nslist() Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260814190022.1531236-1-kumar.shivam43666@gmail.com \
    --to=kumar.shivam43666@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=security@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox