linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
@ 2021-03-15 14:56 ngottlieb
  2021-03-15 21:10 ` Chaitanya Kulkarni
  2021-03-18  5:18 ` Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: ngottlieb @ 2021-03-15 14:56 UTC (permalink / raw)
  To: mgurtovoy, sagi, hch, kbusch, chaitanya.kulkarni, linux-nvme
  Cc: Noam Gottlieb

From: Noam Gottlieb <ngottlieb@nvidia.com>

According to the NVM specifications, the model number size should be
40 bytes (bytes 63:24 of the Identify Controller data structure).
Therefore, any attempt to store a value into model_number which
exceeds 40 bytes should return an error.

Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: Noam Gottlieb <ngottlieb@nvidia.com>
---
 drivers/nvme/target/configfs.c | 6 ++++++
 drivers/nvme/target/nvmet.h    | 1 +
 2 files changed, 7 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 635a7cb45d0b..40c8980387a6 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1150,6 +1150,12 @@ static ssize_t nvmet_subsys_attr_model_store(struct config_item *item,
 	if (!len)
 		return -EINVAL;
 
+	if (len > NVMET_MN_MAX_SIZE) {
+		pr_err("Model nubmer size can not exceed %d Bytes\n",
+		       NVMET_MN_MAX_SIZE);
+		return -EINVAL;
+	}
+
 	for (pos = 0; pos < len; pos++) {
 		if (!nvmet_is_ascii(page[pos]))
 			return -EINVAL;
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index cdfa537b1c0a..6871dd2884f9 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -27,6 +27,7 @@
 #define NVMET_ERROR_LOG_SLOTS		128
 #define NVMET_NO_ERROR_LOC		((u16)-1)
 #define NVMET_DEFAULT_CTRL_MODEL	"Linux"
+#define NVMET_MN_MAX_SIZE		40
 
 /*
  * Supported optional AENs:
-- 
2.18.2


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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-15 14:56 [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes ngottlieb
@ 2021-03-15 21:10 ` Chaitanya Kulkarni
  2021-03-15 21:50   ` Sagi Grimberg
  2021-03-18  5:18 ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-03-15 21:10 UTC (permalink / raw)
  To: ngottlieb, mgurtovoy, sagi, hch, kbusch, linux-nvme

On 3/15/21 07:56, ngottlieb@nvidia.com wrote:
> From: Noam Gottlieb <ngottlieb@nvidia.com>
>
> According to the NVM specifications, the model number size should be
> 40 bytes (bytes 63:24 of the Identify Controller data structure).
> Therefore, any attempt to store a value into model_number which
> exceeds 40 bytes should return an error.
>
> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
> Signed-off-by: Noam Gottlieb <ngottlieb@nvidia.com>

The patch looks good to me, but is this patch not intended for 5.13 ?

Since for 5.13 we have nvmet_subsys_attr_model_store_locked(), this
patch uses nvmet_subsys_attr_model_store().

Is this a fix for 5.12-rc  ?



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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-15 21:10 ` Chaitanya Kulkarni
@ 2021-03-15 21:50   ` Sagi Grimberg
  2021-03-16  3:40     ` Chaitanya Kulkarni
  0 siblings, 1 reply; 8+ messages in thread
From: Sagi Grimberg @ 2021-03-15 21:50 UTC (permalink / raw)
  To: Chaitanya Kulkarni, ngottlieb, mgurtovoy, hch, kbusch, linux-nvme


>> According to the NVM specifications, the model number size should be
>> 40 bytes (bytes 63:24 of the Identify Controller data structure).
>> Therefore, any attempt to store a value into model_number which
>> exceeds 40 bytes should return an error.
>>
>> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
>> Signed-off-by: Noam Gottlieb <ngottlieb@nvidia.com>
> 
> The patch looks good to me, but is this patch not intended for 5.13 ?
> 
> Since for 5.13 we have nvmet_subsys_attr_model_store_locked(), this
> patch uses nvmet_subsys_attr_model_store().
> 
> Is this a fix for 5.12-rc  ?

I think this patch can wait for 5.13 for sure, maybe needs a Fixes
tag to help it get back to stable...

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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-15 21:50   ` Sagi Grimberg
@ 2021-03-16  3:40     ` Chaitanya Kulkarni
  2021-03-16  8:35       ` Max Gurtovoy
  0 siblings, 1 reply; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-03-16  3:40 UTC (permalink / raw)
  To: mgurtovoy; +Cc: Sagi Grimberg, ngottlieb, hch, kbusch, linux-nvme

Max,

On 3/15/21 14:50, Sagi Grimberg wrote:
>>> According to the NVM specifications, the model number size should be
>>> 40 bytes (bytes 63:24 of the Identify Controller data structure).
>>> Therefore, any attempt to store a value into model_number which
>>> exceeds 40 bytes should return an error.
>>>
>>> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
>>> Signed-off-by: Noam Gottlieb <ngottlieb@nvidia.com>
>> The patch looks good to me, but is this patch not intended for 5.13 ?
>>
>> Since for 5.13 we have nvmet_subsys_attr_model_store_locked(), this
>> patch uses nvmet_subsys_attr_model_store().
>>
>> Is this a fix for 5.12-rc  ?
> I think this patch can wait for 5.13 for sure, maybe needs a Fixes
> tag to help it get back to stable...
>

That's what I thought, can you please respin unless there is a reason for
this to be in 5.12 ?





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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-16  3:40     ` Chaitanya Kulkarni
@ 2021-03-16  8:35       ` Max Gurtovoy
  2021-03-16 18:30         ` Sagi Grimberg
  2021-03-16 18:32         ` Chaitanya Kulkarni
  0 siblings, 2 replies; 8+ messages in thread
From: Max Gurtovoy @ 2021-03-16  8:35 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: Sagi Grimberg, ngottlieb, hch, kbusch, linux-nvme


On 3/16/2021 5:40 AM, Chaitanya Kulkarni wrote:
> Max,
>
> On 3/15/21 14:50, Sagi Grimberg wrote:
>>>> According to the NVM specifications, the model number size should be
>>>> 40 bytes (bytes 63:24 of the Identify Controller data structure).
>>>> Therefore, any attempt to store a value into model_number which
>>>> exceeds 40 bytes should return an error.
>>>>
>>>> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
>>>> Signed-off-by: Noam Gottlieb <ngottlieb@nvidia.com>
>>> The patch looks good to me, but is this patch not intended for 5.13 ?
>>>
>>> Since for 5.13 we have nvmet_subsys_attr_model_store_locked(), this
>>> patch uses nvmet_subsys_attr_model_store().
>>>
>>> Is this a fix for 5.12-rc  ?
>> I think this patch can wait for 5.13 for sure, maybe needs a Fixes
>> tag to help it get back to stable...
>>
> That's what I thought, can you please respin unless there is a reason for
> this to be in 5.12 ?

The function nvmet_subsys_attr_model_store_locked also exist in 5.12 and 
this patch applies on it.

I'm not sure it can't go to 5.12 but no problem we can re-spin it for 5.13.

I guess for Fixes tag we can use commit "013b7ebe5a0d70e nvmet: make 
ctrl model configurable" , right ?


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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-16  8:35       ` Max Gurtovoy
@ 2021-03-16 18:30         ` Sagi Grimberg
  2021-03-16 18:32         ` Chaitanya Kulkarni
  1 sibling, 0 replies; 8+ messages in thread
From: Sagi Grimberg @ 2021-03-16 18:30 UTC (permalink / raw)
  To: Max Gurtovoy, Chaitanya Kulkarni; +Cc: ngottlieb, hch, kbusch, linux-nvme


> I guess for Fixes tag we can use commit "013b7ebe5a0d70e nvmet: make 
> ctrl model configurable" , right ?

Yes

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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-16  8:35       ` Max Gurtovoy
  2021-03-16 18:30         ` Sagi Grimberg
@ 2021-03-16 18:32         ` Chaitanya Kulkarni
  1 sibling, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2021-03-16 18:32 UTC (permalink / raw)
  To: Max Gurtovoy; +Cc: Sagi Grimberg, ngottlieb, hch, kbusch, linux-nvme

On 3/16/21 01:35, Max Gurtovoy wrote:
>>>> Is this a fix for 5.12-rc  ?
>>> I think this patch can wait for 5.13 for sure, maybe needs a Fixes
>>> tag to help it get back to stable...
>>>
>> That's what I thought, can you please respin unless there is a reason for
>> this to be in 5.12 ?
> The function nvmet_subsys_attr_model_store_locked also exist in 5.12 and 
> this patch applies on it.

I see.

> I'm not sure it can't go to 5.12 but no problem we can re-spin it for 5.13.
>
> I guess for Fixes tag we can use commit "013b7ebe5a0d70e nvmet: make 
> ctrl model configurable" , right ?

Yes, except sha should be 12 digit 013b7ebe5a0d like :-

    Fixes: ed7770f66286 ("nvme/hwmon: rework to avoid devm allocation")


>


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

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

* Re: [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes
  2021-03-15 14:56 [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes ngottlieb
  2021-03-15 21:10 ` Chaitanya Kulkarni
@ 2021-03-18  5:18 ` Christoph Hellwig
  1 sibling, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2021-03-18  5:18 UTC (permalink / raw)
  To: ngottlieb; +Cc: mgurtovoy, sagi, hch, kbusch, chaitanya.kulkarni, linux-nvme

Thanks,

applied to nvme-5.13.

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

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

end of thread, other threads:[~2021-03-18  5:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-15 14:56 [PATCH 1/1] nvmet: do not allow model_number exceed 40 bytes ngottlieb
2021-03-15 21:10 ` Chaitanya Kulkarni
2021-03-15 21:50   ` Sagi Grimberg
2021-03-16  3:40     ` Chaitanya Kulkarni
2021-03-16  8:35       ` Max Gurtovoy
2021-03-16 18:30         ` Sagi Grimberg
2021-03-16 18:32         ` Chaitanya Kulkarni
2021-03-18  5:18 ` Christoph Hellwig

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).