Skip to content

Commit

Permalink
nvmet: Identify-Active Namespace ID List command should reject invali…
Browse files Browse the repository at this point in the history
…d 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>
  • Loading branch information
Maurizio Lombardi authored and Keith Busch committed Sep 3, 2024
1 parent 28982ad commit 899d2e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/nvme/target/admin-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 899d2e5

Please sign in to comment.