scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
Subsystems (3)
PATCH 1/1 scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
The "mybuf" string comes from the user, so we need to ensure that it is NUL terminated.
--- drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +2 -2
@@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,char mybuf[64 ];char *pbuf; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >63 ) + nbytes =63 ;memset (mybuf,0 ,sizeof (mybuf));
Signature · 1 line
2.20.1
Quoted 9 lines · Dan Carpenter
The "mybuf" string comes from the user, so we need to ensure that it is NUL terminated.
Fixes bd2cdd5e400f ("scsi: lpfc: NVME Initiator: Add debugfs support")Signed-off-by Dan Carpenter <[email protected]>--- drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks Dan. Looks Good.
-- james
Martin K. Petersen
AppliedQuoted 4 lines · Dan Carpenter
The "mybuf" string comes from the user, so we need to ensure that it is NUL terminated.
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
https://git.kernel.org/mkp/scsi/c/9020be114a47
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 4 lines · Dan Carpenter
The "mybuf" string comes from the user, so we need to ensure that it is NUL terminated.
Applied to 5.16/scsi-fixes, thanks!
[1/1] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
https://git.kernel.org/mkp/scsi/c/9020be114a47
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 16 lines · Dan Carpenter
The "mybuf" string comes from the user, so we need to ensure that it is NUL terminated.
Fixes bd2cdd5e400f ("scsi: lpfc: NVME Initiator: Add debugfssupport")
Signed-off-by Dan Carpenter <[email protected]>--- drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/lpfc/lpfc_debugfs.c +0
-0
drivers/scsi/lpfc/lpfc_debugfs.c lpfc_debugfs_nvmeio_trc_write(struct file · line 2959
Quoted 8 lines
drivers/scsi/lpfc/lpfc_debugfs.c +2
-2@@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf, char mybuf[64];char *pbuf; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >63 ) + nbytes =63 ;
Just for future reference, next time could we do
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;
just so we minimize the possibility of screw ups in the unlikely event that someone reduces the size of the mybuf array?
James
Quoted 28 lines · James Bottomley
Quoted 16 lines · Dan Carpenter
The "mybuf" string comes from the user, so we need to ensure that it is NUL terminated.
Fixes bd2cdd5e400f ("scsi: lpfc: NVME Initiator: Add debugfssupport")
Signed-off-by Dan Carpenter <[email protected]>--- drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/lpfc/lpfc_debugfs.c +0
-0drivers/scsi/lpfc/lpfc_debugfs.c lpfc_debugfs_nvmeio_trc_write(struct file · line 2959
Quoted 8 lines
drivers/scsi/lpfc/lpfc_debugfs.c +2
-2@@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf, char mybuf[64];char *pbuf; -if (nbytes >64 ) - nbytes =64 ; +if (nbytes >63 ) + nbytes =63 ;Just for future reference, next time could we do
Quoted 5 lines
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;just so we minimize the possibility of screw ups in the unlikely event that someone reduces the size of the mybuf array?
Yeah. Good point. Will do that next time.
regards,
dan carpenter