* [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
@ 2021-12-14 7:05 Dan Carpenter
2021-12-14 15:10 ` James Smart
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-12-14 7:05 UTC (permalink / raw)
To: James Smart, Dick Kennedy
Cc: James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
linux-scsi, kernel-janitors
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 <dan.carpenter@oracle.com>
---
drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 21152c9a96ef..30fac2f6fb06 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -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));
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
2021-12-14 7:05 [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write() Dan Carpenter
@ 2021-12-14 15:10 ` James Smart
2021-12-17 4:04 ` Martin K. Petersen
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: James Smart @ 2021-12-14 15:10 UTC (permalink / raw)
To: Dan Carpenter, James Smart, Dick Kennedy
Cc: James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
linux-scsi, kernel-janitors
On 12/13/2021 11:05 PM, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---
> drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
Thanks Dan. Looks Good.
Reviewed-by: James Smart <jsmart2021@gmail.com>
-- james
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
2021-12-14 7:05 [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write() Dan Carpenter
2021-12-14 15:10 ` James Smart
@ 2021-12-17 4:04 ` Martin K. Petersen
2021-12-23 5:08 ` Martin K. Petersen
2021-12-31 14:55 ` James Bottomley
3 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2021-12-17 4:04 UTC (permalink / raw)
To: Dick Kennedy, James Smart, Dan Carpenter
Cc: Martin K . Petersen, Hannes Reinecke, James E.J. Bottomley,
kernel-janitors, linux-scsi
On Tue, 14 Dec 2021 10:05:27 +0300, Dan Carpenter wrote:
> 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
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
2021-12-14 7:05 [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write() Dan Carpenter
2021-12-14 15:10 ` James Smart
2021-12-17 4:04 ` Martin K. Petersen
@ 2021-12-23 5:08 ` Martin K. Petersen
2021-12-31 14:55 ` James Bottomley
3 siblings, 0 replies; 6+ messages in thread
From: Martin K. Petersen @ 2021-12-23 5:08 UTC (permalink / raw)
To: Dan Carpenter, Dick Kennedy, James Smart
Cc: Martin K . Petersen, linux-scsi, James E.J. Bottomley,
kernel-janitors, Hannes Reinecke
On Tue, 14 Dec 2021 10:05:27 +0300, Dan Carpenter wrote:
> 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
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
2021-12-14 7:05 [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write() Dan Carpenter
` (2 preceding siblings ...)
2021-12-23 5:08 ` Martin K. Petersen
@ 2021-12-31 14:55 ` James Bottomley
2022-01-07 9:31 ` Dan Carpenter
3 siblings, 1 reply; 6+ messages in thread
From: James Bottomley @ 2021-12-31 14:55 UTC (permalink / raw)
To: Dan Carpenter, James Smart, Dick Kennedy
Cc: Martin K. Petersen, Hannes Reinecke, linux-scsi, kernel-janitors
On Tue, 2021-12-14 at 10:05 +0300, Dan Carpenter wrote:
> 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 <dan.carpenter@oracle.com>
> ---
> drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c
> b/drivers/scsi/lpfc/lpfc_debugfs.c
> index 21152c9a96ef..30fac2f6fb06 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
2021-12-31 14:55 ` James Bottomley
@ 2022-01-07 9:31 ` Dan Carpenter
0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-01-07 9:31 UTC (permalink / raw)
To: James Bottomley
Cc: James Smart, Dick Kennedy, Martin K. Petersen, Hannes Reinecke,
linux-scsi, kernel-janitors
On Fri, Dec 31, 2021 at 09:55:00AM -0500, James Bottomley wrote:
> On Tue, 2021-12-14 at 10:05 +0300, Dan Carpenter wrote:
> > 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 <dan.carpenter@oracle.com>
> > ---
> > drivers/scsi/lpfc/lpfc_debugfs.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c
> > b/drivers/scsi/lpfc/lpfc_debugfs.c
> > index 21152c9a96ef..30fac2f6fb06 100644
> > --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> > +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> > @@ -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?
Yeah. Good point. Will do that next time.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-07 9:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-14 7:05 [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write() Dan Carpenter
2021-12-14 15:10 ` James Smart
2021-12-17 4:04 ` Martin K. Petersen
2021-12-23 5:08 ` Martin K. Petersen
2021-12-31 14:55 ` James Bottomley
2022-01-07 9:31 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.