All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet: Identify-Active Namespace ID List command should reject invalid nsid
@ 2024-08-28 12:21 Maurizio Lombardi
  2024-08-29  5:31 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Maurizio Lombardi @ 2024-08-28 12:21 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>
---
 drivers/nvme/target/admin-cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index f7e1156ac7ec..d37bb1cb94fa 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -587,6 +587,12 @@ static void nvmet_execute_identify_nslist(struct nvmet_req *req)
 	u16 status = 0;
 	int i = 0;
 
+	if (min_nsid >= NVME_NSID_ALL - 1) {
+		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] 2+ messages in thread

* Re: [PATCH] nvmet: Identify-Active Namespace ID List command should reject invalid nsid
  2024-08-28 12:21 [PATCH] nvmet: Identify-Active Namespace ID List command should reject invalid nsid Maurizio Lombardi
@ 2024-08-29  5:31 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2024-08-29  5:31 UTC (permalink / raw)
  To: Maurizio Lombardi; +Cc: hch, sagi, kch, linux-nvme, kbusch

On Wed, Aug 28, 2024 at 02:21:29PM +0200, Maurizio Lombardi wrote:
> +	if (min_nsid >= NVME_NSID_ALL - 1) {

It would almost seem cleaner to check for the two magic constant.
Either way please put a comment in with the spec reference as the code
is rather non-obvious with out.



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

end of thread, other threads:[~2024-08-29  5:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 12:21 [PATCH] nvmet: Identify-Active Namespace ID List command should reject invalid nsid Maurizio Lombardi
2024-08-29  5:31 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.