Skip to contentSkip to conversation

nvmet: return Invalid Field error on set features cmd fid 07h

PATCH In review [email protected] 2 participants 3 messages Feb 27, 2020 – Feb 28, 2020

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

PATCH 1/1 nvmet: return Invalid Field error on set features cmd fid 07h

From: Amit Engel <[email protected]>

If the value specified in NCQR and NSQR fields (0's based) is 65,535 the controller should return an error of Invalid field in command

---
 drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +10 -1
index 19f949570625..f76b44768100 100644
@@ -733,16 +733,25 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
 {
 	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
 	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
+	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
 	u16 status = 0;
 
 	if (!nvmet_check_data_len(req, 0))
 		return;
 
 	switch (cdw10 & 0xff) {
-	case NVME_FEAT_NUM_QUEUES:
+	case NVME_FEAT_NUM_QUEUES: {
+		u16 ncqr = (cdw11 >> 16) & 0xffff;
+		u16 nsqr = cdw11 & 0xffff;
+
+		if (ncqr == 0xffff || nsqr == 0xffff) {
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+			break;
+		}
 		nvmet_set_result(req,
 			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
 		break;
+	}
 	case NVME_FEAT_KATO:
 		status = nvmet_set_feat_kato(req);
 		break;
Signature · 7 lines
2.16.5


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#1 lore raw
Quoted 29 lines

From: Amit Engel <[email protected]>

If the value specified in NCQR and NSQR fields (0's based) is 65,535 the controller should return an error of Invalid field in command

---
  drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
drivers/nvme/target/admin-cmd.c +3 -1
index 19f949570625..f76b44768100 100644
@@ -733,16 +733,25 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
  {
  	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
  	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
+	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
  	u16 status = 0;
 
  	if (!nvmet_check_data_len(req, 0))
  		return;
 
  	switch (cdw10 & 0xff) {
-	case NVME_FEAT_NUM_QUEUES:
+	case NVME_FEAT_NUM_QUEUES: {
+		u16 ncqr = (cdw11 >> 16) & 0xffff;

drivers/nvme/target/admin-cmd.c static void nvmet_execute_set_features(struct nvmet_req *req) · line 754

Quoted 10 lines
drivers/nvme/target/admin-cmd.c +7 -0
+		u16 nsqr = cdw11 & 0xffff;
+
+		if (ncqr == 0xffff || nsqr == 0xffff) {
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+			break;
+		}
  		nvmet_set_result(req,
  			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
  		break;
+	}

I'd avoid parenthesis in the switch-case statement, just declare them on top and assign them here.

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#2 lore raw

Sure, I just uploaded a fixed patch

Thanks
Amit Engel

-----Original Message-----
From: Sagi Grimberg <[email protected]>
Sent: Friday, February 28, 2020 1:16 AM
To: Engel, Amit; [email protected]
Subject: Re: [PATCH] nvmet: return Invalid Field error on set features cmd fid 07h

[EXTERNAL EMAIL]

Quoted 29 lines

From: Amit Engel <[email protected]>

If the value specified in NCQR and NSQR fields (0's based) is 65,535 the controller should return an error of Invalid field in command

---
  drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/nvme/target/admin-cmd.c index 19f949570625..f76b44768100 100644

drivers/nvme/target/admin-cmd.c +3 -1
@@ -733,16 +733,25 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
  {
  	struct nvmet_subsys *subsys = req->sq->ctrl->subsys;
  	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
+	u32 cdw11 = le32_to_cpu(req->cmd->common.cdw11);
  	u16 status = 0;
 
  	if (!nvmet_check_data_len(req, 0))
  		return;
 
  	switch (cdw10 & 0xff) {
-	case NVME_FEAT_NUM_QUEUES:
+	case NVME_FEAT_NUM_QUEUES: {
+		u16 ncqr = (cdw11 >> 16) & 0xffff;

drivers/nvme/target/admin-cmd.c static void nvmet_execute_set_features(struct nvmet_req *req) · line 754

Quoted 10 lines
drivers/nvme/target/admin-cmd.c +7 -0
+		u16 nsqr = cdw11 & 0xffff;
+
+		if (ncqr == 0xffff || nsqr == 0xffff) {
+			status = NVME_SC_INVALID_FIELD | NVME_SC_DNR;
+			break;
+		}
  		nvmet_set_result(req,
  			(subsys->max_qid - 1) | ((subsys->max_qid - 1) << 16));
  		break;
+	}

I'd avoid parenthesis in the switch-case statement, just declare them on top and assign them here.
_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme