scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 14 Dec 2021 07:05:27 +0000 (10:05 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Jan 2022 11:40:30 +0000 (12:40 +0100)
[ Upstream commit 9020be114a47bf7ff33e179b3bb0016b91a098e6 ]

The "mybuf" string comes from the user, so we need to ensure that it is NUL
terminated.

Link: https://lore.kernel.org/r/20211214070527.GA27934@kili
Fixes: bd2cdd5e400f ("scsi: lpfc: NVME Initiator: Add debugfs support")
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/lpfc/lpfc_debugfs.c

index b89c5513243e8e81dfcdfe0a7c1949b5eef154c6..beaf3a8d206f8096396a95600652262df7a65917 100644 (file)
@@ -2956,8 +2956,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));