Skip to content

Commit 899d2e5

Browse files
maurizio-lombardikeithbusch
authored andcommitted
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: a07b497 ("nvmet: add a generic NVMe target") Signed-off-by: Maurizio Lombardi <mlombard@redhat.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 28982ad commit 899d2e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/nvme/target/admin-cmd.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
587587
u16 status = 0;
588588
int i = 0;
589589

590+
/*
591+
* NSID values 0xFFFFFFFE and NVME_NSID_ALL are invalid
592+
* See NVMe Base Specification, Active Namespace ID list (CNS 02h).
593+
*/
594+
if (min_nsid == 0xFFFFFFFE || min_nsid == NVME_NSID_ALL) {
595+
req->error_loc = offsetof(struct nvme_identify, nsid);
596+
status = NVME_SC_INVALID_NS | NVME_STATUS_DNR;
597+
goto out;
598+
}
599+
590600
list = kzalloc(buf_size, GFP_KERNEL);
591601
if (!list) {
592602
status = NVME_SC_INTERNAL;

0 commit comments

Comments
 (0)