linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
@ 2019-12-05  8:15 Amit
  2019-12-05  8:33 ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: Amit @ 2019-12-05  8:15 UTC (permalink / raw)
  To: sagi, linux-nvme; +Cc: amit.engel

From: Amit Engel <amit.engel@dell.com>

In feature id 0x81 NVME_FEAT_HOST_ID, nvmet_copy_to_sgl is called
req->data_len shall hold a non-zero value which is
'sizeof(req->sq->ctrl->hostid)'

Signed-off-by: Amit Engel <amit.engel@dell.com>
---
 drivers/nvme/target/admin-cmd.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 831a062d27cb..0e1668274872 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -812,6 +812,7 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 {
 	struct nvme_command *cmd = req->cmd;
 	u16 ret;
+	u8 feature;
 
 	ret = nvmet_check_ctrl_status(req, cmd);
 	if (unlikely(ret))
@@ -875,7 +876,10 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
 		return 0;
 	case nvme_admin_get_features:
 		req->execute = nvmet_execute_get_features;
-		req->data_len = 0;
+		if (feature == NVME_FEAT_HOST_ID)
+			req->data_len = sizeof(req->sq->ctrl->hostid);
+		else
+			req->data_len = 0;
 		return 0;
 	case nvme_admin_async_event:
 		req->execute = nvmet_execute_async_event;
-- 
2.16.5


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
  2019-12-05  8:15 [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81 Amit
@ 2019-12-05  8:33 ` Christoph Hellwig
  2019-12-05 13:35   ` Engel, Amit
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2019-12-05  8:33 UTC (permalink / raw)
  To: Amit; +Cc: sagi, linux-nvme

->data_len is gone in latest mainline, instead
nvmet_execute_get_features check the transfer_len.  But your
general scheme should apply there.  I think a little
nvmet_feature_data_len helper to calculate the required length
would be nice, similar to what we do for read/write commands or
log pages.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* RE: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
  2019-12-05  8:33 ` Christoph Hellwig
@ 2019-12-05 13:35   ` Engel, Amit
  2019-12-09 13:21     ` Engel, Amit
  0 siblings, 1 reply; 7+ messages in thread
From: Engel, Amit @ 2019-12-05 13:35 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: sagi, linux-nvme

Ok, please ignore my previous patches from earlier today.
I just sent a new patch based on nvme-5.5 
"Add helper function 'nvmet_feature_data_len' to calculate the required data_len"

Please let me know what you think

Thanks
Amit Engel

-----Original Message-----
From: Christoph Hellwig <hch@infradead.org> 
Sent: Thursday, December 5, 2019 10:33 AM
To: Engel, Amit
Cc: sagi@grimberg.me; linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81


[EXTERNAL EMAIL] 

->data_len is gone in latest mainline, instead
nvmet_execute_get_features check the transfer_len.  But your general scheme should apply there.  I think a little nvmet_feature_data_len helper to calculate the required length would be nice, similar to what we do for read/write commands or log pages.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* RE: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
  2019-12-05 13:35   ` Engel, Amit
@ 2019-12-09 13:21     ` Engel, Amit
  2019-12-10  7:23       ` Chaitanya Kulkarni
  0 siblings, 1 reply; 7+ messages in thread
From: Engel, Amit @ 2019-12-09 13:21 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: sagi, linux-nvme

Hi, 

Did you receive my latest patch fix for the below bug?

Thanks
Amit

-----Original Message-----
From: Engel, Amit 
Sent: Thursday, December 5, 2019 3:36 PM
To: Christoph Hellwig
Cc: sagi@grimberg.me; linux-nvme@lists.infradead.org
Subject: RE: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81

Ok, please ignore my previous patches from earlier today.
I just sent a new patch based on nvme-5.5 "Add helper function 'nvmet_feature_data_len' to calculate the required data_len"

Please let me know what you think

Thanks
Amit Engel

-----Original Message-----
From: Christoph Hellwig <hch@infradead.org>
Sent: Thursday, December 5, 2019 10:33 AM
To: Engel, Amit
Cc: sagi@grimberg.me; linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81


[EXTERNAL EMAIL] 

->data_len is gone in latest mainline, instead
nvmet_execute_get_features check the transfer_len.  But your general scheme should apply there.  I think a little nvmet_feature_data_len helper to calculate the required length would be nice, similar to what we do for read/write commands or log pages.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* Re: [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
  2019-12-09 13:21     ` Engel, Amit
@ 2019-12-10  7:23       ` Chaitanya Kulkarni
  0 siblings, 0 replies; 7+ messages in thread
From: Chaitanya Kulkarni @ 2019-12-10  7:23 UTC (permalink / raw)
  To: Engel, Amit, Christoph Hellwig; +Cc: sagi, linux-nvme

On 12/09/2019 05:22 AM, Engel, Amit wrote:
> Hi,
>
> Did you receive my latest patch fix for the below bug?
>
> Thanks
> Amit

There 3 patches on the mailing list.

I've just posted a patch with some fixes on the top of your patch.

_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
@ 2019-12-05 13:14 Amit
  0 siblings, 0 replies; 7+ messages in thread
From: Amit @ 2019-12-05 13:14 UTC (permalink / raw)
  To: sagi, linux-nvme; +Cc: amit.engel

From: Amit Engel <amit.engel@dell.com>

In feature id 0x81 NVME_FEAT_HOST_ID, nvmet_copy_to_sgl is called
req->data_len shall hold a non-zero value which is
'sizeof(req->sq->ctrl->hostid)'

Signed-off-by: Amit Engel <amit.engel@dell.com>
---
 drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
 drivers/nvme/target/nvmet.h     |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 56c21b501185..f09d5fdc995f 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -24,6 +24,15 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)
 	return len;
 }
 
+u32 nvmet_feature_data_len(struct nvmet_req *req)
+{
+	u8 feature = req->cmd->common.cdw10 & 0xff;
+
+	if (feature == NVME_FEAT_HOST_ID)
+		return sizeof(req->sq->ctrl->hostid);
+	return 0;
+}
+
 u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
 {
 	return le64_to_cpu(cmd->get_log_page.lpo);
@@ -778,7 +787,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
 	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
 	u16 status = 0;
 
-	if (!nvmet_check_data_len(req, 0))
+	if (!nvmet_check_data_len(req, nvmet_feature_data_len(req))
 		return;
 
 	switch (cdw10 & 0xff) {
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index 46df45e837c9..6422489d96cd 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -434,6 +434,8 @@ u16 nvmet_zero_sgl(struct nvmet_req *req, off_t off, size_t len);
 u32 nvmet_get_log_page_len(struct nvme_command *cmd);
 u64 nvmet_get_log_page_offset(struct nvme_command *cmd);
 
+u32 nvmet_feature_data_len(struct nvmet_req *req);
+
 extern struct list_head *nvmet_ports;
 void nvmet_port_disc_changed(struct nvmet_port *port,
 		struct nvmet_subsys *subsys);
-- 
2.16.5


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

* [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81
@ 2019-12-05 13:10 Amit
  0 siblings, 0 replies; 7+ messages in thread
From: Amit @ 2019-12-05 13:10 UTC (permalink / raw)
  To: sagi, linux-nvme; +Cc: amit.engel

From: Amit Engel <amit.engel@dell.com>

In feature id 0x81 NVME_FEAT_HOST_ID, nvmet_copy_to_sgl is called
req->data_len shall hold a non-zero value which is
'sizeof(req->sq->ctrl->hostid)'

Signed-off-by: Amit Engel <amit.engel@dell.com>
---
 drivers/nvme/target/admin-cmd.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 56c21b501185..f09d5fdc995f 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -24,6 +24,15 @@ u32 nvmet_get_log_page_len(struct nvme_command *cmd)
 	return len;
 }
 
+u32 nvmet_feature_data_len(struct nvmet_req *req)
+{
+	u8 feature = req->cmd->common.cdw10 & 0xff;
+
+	if (feature == NVME_FEAT_HOST_ID)
+		return sizeof(req->sq->ctrl->hostid);
+	return 0;
+}
+
 u64 nvmet_get_log_page_offset(struct nvme_command *cmd)
 {
 	return le64_to_cpu(cmd->get_log_page.lpo);
@@ -778,7 +787,7 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
 	u32 cdw10 = le32_to_cpu(req->cmd->common.cdw10);
 	u16 status = 0;
 
-	if (!nvmet_check_data_len(req, 0))
+	if (!nvmet_check_data_len(req, nvmet_feature_data_len(req))
 		return;
 
 	switch (cdw10 & 0xff) {
-- 
2.16.5


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

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

end of thread, other threads:[~2019-12-10  7:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-05  8:15 [PATCH] nvmet: Fix req->data_len size in case of nvme_admin_get_features cmd, fid 0x81 Amit
2019-12-05  8:33 ` Christoph Hellwig
2019-12-05 13:35   ` Engel, Amit
2019-12-09 13:21     ` Engel, Amit
2019-12-10  7:23       ` Chaitanya Kulkarni
2019-12-05 13:10 Amit
2019-12-05 13:14 Amit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).