From: Dan Carpenter <dan.carpenter@oracle.com>
To: James Bottomley <jejb@linux.ibm.com>
Cc: James Smart <james.smart@broadcom.com>,
Dick Kennedy <dick.kennedy@broadcom.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Hannes Reinecke <hare@suse.com>,
linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
Date: Fri, 7 Jan 2022 12:31:03 +0300 [thread overview]
Message-ID: <20220107093103.GR7674@kadam> (raw)
In-Reply-To: <fca6717d704ffa33cfd9d3cba519da8705195858.camel@linux.ibm.com>
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
prev parent reply other threads:[~2022-01-07 9:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220107093103.GR7674@kadam \
--to=dan.carpenter@oracle.com \
--cc=dick.kennedy@broadcom.com \
--cc=hare@suse.com \
--cc=james.smart@broadcom.com \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox