Skip to contentSkip to conversation

nvmet: Identify-Active Namespace ID List command should reject invalid nsid

PATCH Applied Maurizio Lombardi 3 participants 3 messages Aug 29, 2024 – Aug 30, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvmet: Identify-Active Namespace ID List command should reject invalid nsid

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")

---

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(+)
drivers/nvme/target/admin-cmd.c +10 -0
index f7e1156ac7ec..85006b2df8ae 100644
@@ -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;
Signature · 1 line
2.43.5
maintainer Applied
#2 lore raw
In reply to Maurizio Lombardi
Quoted 3 lines · Maurizio Lombardi

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.