Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] nvmet: Identify-Active Namespace ID List command should reject invalid nsid
@ 2024-08-29  9:52 Maurizio Lombardi
  2024-08-30 10:03 ` Sagi Grimberg
  2024-08-30 14:36 ` Keith Busch
  0 siblings, 2 replies; 3+ messages in thread
From: Maurizio Lombardi @ 2024-08-29  9:52 UTC (permalink / raw)
  To: hch; +Cc: sagi, kch, linux-nvme, kbusch

nsid values of 0xFFFFFFFE and 0XFFFFFFFF should be rejected with
a status code of "Invalid Namespace or Format".
See NVMe Base Specification, Active Namespace ID list (CNS 02h).

Fixes: a07b4970f464 ("nvmet: add a generic NVMe target")
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---

v2: Explicitely check against the two constants, add a reference to the specs

 drivers/nvme/target/admin-cmd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index f7e1156ac7ec..85006b2df8ae 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -587,6 +587,16 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	u16 status = 0;
 	int i = 0;
 
+	/*
+	 * NSID values 0xFFFFFFFE and NVME_NSID_ALL are invalid
+	 * See NVMe Base Specification, Active Namespace ID list (CNS 02h).
+	 */
+	if (min_nsid == 0xFFFFFFFE || min_nsid == NVME_NSID_ALL) {
+		req->error_loc = offsetof(struct nvme_identify, nsid);
+		status = NVME_SC_INVALID_NS | NVME_STATUS_DNR;
+		goto out;
+	}
+
 	list = kzalloc(buf_size, GFP_KERNEL);
 	if (!list) {
 		status = NVME_SC_INTERNAL;
-- 
2.43.5



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] nvmet: Identify-Active Namespace ID List command should reject invalid nsid
  2024-08-29  9:52 [PATCH V2] nvmet: Identify-Active Namespace ID List command should reject invalid nsid Maurizio Lombardi
@ 2024-08-30 10:03 ` Sagi Grimberg
  2024-08-30 14:36 ` Keith Busch
  1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2024-08-30 10:03 UTC (permalink / raw)
  To: Maurizio Lombardi, hch; +Cc: kch, linux-nvme, kbusch

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] nvmet: Identify-Active Namespace ID List command should reject invalid nsid
  2024-08-29  9:52 [PATCH V2] nvmet: Identify-Active Namespace ID List command should reject invalid nsid Maurizio Lombardi
  2024-08-30 10:03 ` Sagi Grimberg
@ 2024-08-30 14:36 ` Keith Busch
  1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2024-08-30 14:36 UTC (permalink / raw)
  To: Maurizio Lombardi; +Cc: hch, sagi, kch, linux-nvme, kbusch

On Thu, Aug 29, 2024 at 11:52:14AM +0200, Maurizio Lombardi wrote:
> nsid values of 0xFFFFFFFE and 0XFFFFFFFF should be rejected with
> a status code of "Invalid Namespace or Format".
> See NVMe Base Specification, Active Namespace ID list (CNS 02h).

Thanks, applied to nvme-6.11.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-30 14:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-29  9:52 [PATCH V2] nvmet: Identify-Active Namespace ID List command should reject invalid nsid Maurizio Lombardi
2024-08-30 10:03 ` Sagi Grimberg
2024-08-30 14:36 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox