[PATCH] nvmet: fixup buffer overrun in nvmet_subsys_attr_serial()
Hannes Reinecke
hare at suse.de
Fri Aug 27 02:29:26 PDT 2021
The serial number is copied into the buffer via memcpy_and_pad()
with the length NVMET_SN_MAX_SIZE. So when printing out we also
need to take just that length as anything beyond that will be
uninitialized.
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
drivers/nvme/target/configfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index 008be02fbac9..255db21b73ee 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -1113,7 +1113,7 @@ static ssize_t nvmet_subsys_attr_serial_show(struct config_item *item,
{
struct nvmet_subsys *subsys = to_subsys(item);
- return snprintf(page, PAGE_SIZE, "%s\n", subsys->serial);
+ return snprintf(page, NVMET_SN_MAX_SIZE, "%s\n", subsys->serial);
}
static ssize_t
--
2.29.2
More information about the Linux-nvme
mailing list