summaryrefslogtreecommitdiff
path: root/drivers/nvme/target/configfs.c
diff options
context:
space:
mode:
authorNoam Gottlieb <ngottlieb@nvidia.com>2021-03-15 14:56:11 +0000
committerChristoph Hellwig <hch@lst.de>2021-04-02 18:48:27 +0200
commit48b4c010c85bbd319fbcae79b2d602857a2e9345 (patch)
treeae315b9b172357e5665c8184a145a11be6129195 /drivers/nvme/target/configfs.c
parentde5878048e11f1ec44164ebb8994de132074367a (diff)
nvmet: do not allow model_number exceed 40 bytes
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> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target/configfs.c')
-rw-r--r--drivers/nvme/target/configfs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index e5dbd1923b7b..125ef2c65d5f 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1149,6 +1149,12 @@ static ssize_t nvmet_subsys_attr_model_store_locked(struct nvmet_subsys *subsys,
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;