Commit 48b4c010 authored by Noam Gottlieb's avatar Noam Gottlieb Committed by Christoph Hellwig
Browse files

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: default avatarMax Gurtovoy <mgurtovoy@nvidia.com>
Signed-off-by: default avatarNoam Gottlieb <ngottlieb@nvidia.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent de587804
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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;
+1 −0
Original line number Diff line number Diff line
@@ -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: