From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 72C27C55ABA for ; Tue, 4 Aug 2026 02:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=80JMy/2kLPFykHHgKiRnsR+X/BMINcG6pDzIfK+uaAc=; b=WccD3+sHC9i9mjI5hOoU7xyteL Wt1Xt82Dpbf4JRAZ2YBVpxpo1mXlZbuHuYJmlfmABcCfxLyZV21FKSm4MUm2hYdX3dsQZNXipYQsE U+RH9DWNPcGvEaJMkytpxJ25L78cpTuQ3yzX/xeB9EqJIin+Z1vP2IARQAMCHXbXndlRnj95Gka4w UT0p5xn6A1CQKCp8z5usUAz77Xv4F50vd+tcbpSPrrNrILSu+7yMNJYwo3IztzWvU0hnYAx1z2o/T R83/Qjs2ubt3gZUAbEc9T9CigOQs4Wgi6JU/eo9qwh6RcC3wBH7H/Gik/5ftS720xxyEqn2cSDPRD eoQSQhuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wr4kR-00000000pMZ-2a4t; Tue, 04 Aug 2026 02:19:19 +0000 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wr4kM-00000000pIp-1aIv for linux-nvme@lists.infradead.org; Tue, 04 Aug 2026 02:19:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1785809947; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=80JMy/2kLPFykHHgKiRnsR+X/BMINcG6pDzIfK+uaAc=; b=vcTkSj+XlEIuIOy8JX/SfsaRi10FM0asfA+9MgONeBidoJHiHG5WBAuH1hsukMW+w5UK7PdPelcPSYY0Q+U6d+bsF9qZoj22+d8PWRlXYJVQGVVLwgqfhz6cm6yH7Lj24GQljHbkRzbBtrjefQSorH4Go0owHO1aPVvMNBbRic4= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R271e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=kanie@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0X8MFXIQ_1785809946; Received: from localhost(mailfrom:kanie@linux.alibaba.com fp:SMTPD_---0X8MFXIQ_1785809946 cluster:ay36) by smtp.aliyun-inc.com; Tue, 04 Aug 2026 10:19:07 +0800 From: Guixin Liu To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , nilay@linux.ibm.com, Chaitanya Kulkarni , Kanchan Joshi Cc: linux-nvme@lists.infradead.org Subject: [PATCH v3 1/5] nvmet: fix NULL pointer dereference in nvmet_execute_identify_nslist() Date: Tue, 4 Aug 2026 10:18:57 +0800 Message-ID: <20260804021901.3777326-2-kanie@linux.alibaba.com> X-Mailer: git-send-email 2.43.7 In-Reply-To: <20260804021901.3777326-1-kanie@linux.alibaba.com> References: <20260804021901.3777326-1-kanie@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260803_191915_215640_6B8046BD X-CRM114-Status: GOOD ( 13.74 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org When a host issues an Identify command with CNS 07h (Active Namespace ID List for a specific I/O Command Set), nvmet_execute_identify_nslist() is called with match_css set. The command-set filter dereferences req->ns, but this handler never calls nvmet_req_find_ns(), so req->ns is always NULL (nvmet_req_init() resets it to NULL). As soon as an enabled namespace with an NSID greater than the requested value exists, req->ns->csi dereferences a NULL pointer and oopses. Besides the crash, the comparison is logically wrong: to filter the list by command set it must test the command set of the namespace being iterated, not a single fixed value. Use the loop variable ns->csi. Fixes: 61c9967cd634 ("nvmet: implement active command set ns list") Signed-off-by: Guixin Liu Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Reviewed-by: Nilay Shroff --- 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.43.7