Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 90A9147D46D; Sat, 12 Sep 2026 13:00:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789218046; cv=none; b=Z+Lo2KnwGTJIB6zDk1LUXg9nIS+AOFbjwtzGeH0PKNR99nbImP5rBSB+tESYB/NpB9D/BMqP7UMndMikgpUPJCq+1UGe1pygUXY3wO5MlNkAXAcWK0JveLzJ+iuutOHj5j71A/peB4fn+NSDtKgzL4lRZdKkeLODAzIutcxon5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789218046; c=relaxed/simple; bh=sc8eNXcQsyi3l5BtAs7QFMPgtBGYwBDP3wOJTtPLteE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TJsrAqxJQmljz8PWbr6dZJbqbIgRqEYsLwE4G/oYA+8lUh3L3NsYJGs/fgdABaEy/bCa2vi8uhZ59pyl6OzpxZVyx9t/pRcDt74PzfKUtFhhtX4EmCUZe0o9ljf7fZBIpiEoztifrL+qkdViWaKXvHqB8Iivw2vy/BsgdGpytDI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IVyg5AbF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IVyg5AbF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FD501F000FF; Sat, 12 Sep 2026 13:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789218045; bh=6OdH6huQK1/r+92KC65Q/hR3QJQow0opT8Cwm9h/YRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IVyg5AbFsqqKtrHsns431XMuC53l+RV5DvKh1VAsnzqYiH7RqbPtZEIQ0Ul3m0LHs 1cYqDCW26T82eICStrGjdyubhcWEr00JCQitGxqyn5wEKW7KOTGjzrFcl2h3uFILrH nzZv91UP2ezLGYBYIf6861mta63Pbi0SLMvQ5yeg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Damien Le Moal , Christoph Hellwig , Guixin Liu , Keith Busch , Sasha Levin Subject: [PATCH 6.12 1062/1376] nvmet: fix NULL pointer dereference in nvmet_execute_identify_ns_zns() Date: Sat, 12 Sep 2026 08:58:08 +0200 Message-ID: <20260912065631.228282530@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.535295758@linuxfoundation.org> References: <20260912065607.535295758@linuxfoundation.org> User-Agent: quilt/0.69 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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guixin Liu [ Upstream commit f594863967d87b7fcbff6e724d51135fd701a13d ] When a host issues an Identify command with CNS 05h (I/O Command Set specific Identify Namespace) and CSI 02h (ZNS) targeting a file-backed namespace, nvmet_execute_identify_ns_zns() calls bdev_is_zoned() on req->ns->bdev. A file-backed namespace has no block device, so req->ns->bdev is NULL and bdev_is_zoned() dereferences it, oopsing. The I/O command set is selected by the host-supplied CSI field and the command is routed here whenever CONFIG_BLK_DEV_ZONED is enabled, independent of the namespace backing type, so any file-backed namespace is exposed. Reject the command with Invalid Field when the namespace is not backed by a block device. Fixes: aaf2e048af27 ("nvmet: add ZBD over ZNS backend support") Reviewed-by: Damien Le Moal Reviewed-by: Christoph Hellwig Signed-off-by: Guixin Liu Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/zns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/target/zns.c b/drivers/nvme/target/zns.c index af9e13be76786..40f261a4927ce 100644 --- a/drivers/nvme/target/zns.c +++ b/drivers/nvme/target/zns.c @@ -120,7 +120,7 @@ void nvmet_execute_identify_ns_zns(struct nvmet_req *req) mutex_unlock(&req->ns->subsys->lock); } - if (!bdev_is_zoned(req->ns->bdev)) { + if (!req->ns->bdev || !bdev_is_zoned(req->ns->bdev)) { status = NVME_SC_INVALID_FIELD | NVME_STATUS_DNR; req->error_loc = offsetof(struct nvme_identify, nsid); goto out; -- 2.53.0