Skip to contentSkip to conversation

nvmet: do not allow model_number exceed 40 bytes

PATCH Applied [email protected] 5 participants 8 messages Mar 15, 2021 – Mar 18, 2021

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

PATCH 1/1 nvmet: do not allow model_number exceed 40 bytes

From: Noam Gottlieb <[email protected]>

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.

---
 drivers/nvme/target/configfs.c | 6 ++++++
 drivers/nvme/target/nvmet.h    | 1 +
 2 files changed, 7 insertions(+)
drivers/nvme/target/configfs.c +6 -0
index 635a7cb45d0b..40c8980387a6 100644
@@ -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;
drivers/nvme/target/nvmet.h +1 -0
index cdfa537b1c0a..6871dd2884f9 100644
@@ -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:
Signature · 7 lines
2.18.2


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
#1 lore raw
Quoted 9 lines · On 3/15/21 07:56, [email protected] wrote:

From: Noam Gottlieb <[email protected]>

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.

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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer
#2 lore raw
Quoted 9 lines
Quoted 8 lines

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.

Quoted 6 lines

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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#3 lore raw

Max,

Quoted 7 lines · Sagi Grimberg
Quoted 7 lines
Quoted 7 lines

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.

Quoted 9 lines
Quoted 6 lines

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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#4 lore raw
Quoted 15 lines · Chaitanya Kulkarni

Max,

Quoted 12 lines · Sagi Grimberg
Quoted 12 lines
Quoted 7 lines

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.

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

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

#6 lore raw
In reply to Max Gurtovoy
Quoted 8 lines · Max Gurtovoy
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

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.

Quoted 4 lines

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")
Quoted 1 line

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