diff mbox

lpfc: fix missing zero termination in debugfs

Message ID 20160215191142.19028.9220.stgit@localhost.localdomain (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Alan Cox Feb. 15, 2016, 7:11 p.m. UTC
If you feed 32 bytes in then the kstrtoull() doesn't receive a terminated
string so will run off the end.

Signed-off-by: Alan Cox <alan@linux.intel.com>
---
 drivers/scsi/lpfc/lpfc_debugfs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Johannes Thumshirn Feb. 16, 2016, 6:52 a.m. UTC | #1
On Mon, Feb 15, 2016 at 07:11:56PM +0000, Alan wrote:
> If you feed 32 bytes in then the kstrtoull() doesn't receive a terminated
> string so will run off the end.
> 
> Signed-off-by: Alan Cox <alan@linux.intel.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 25aa9b9..a63542b 100644
> --- a/drivers/scsi/lpfc/lpfc_debugfs.c
> +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
> @@ -1054,11 +1054,11 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
>  {
>  	struct dentry *dent = file->f_path.dentry;
>  	struct lpfc_hba *phba = file->private_data;
> -	char dstbuf[32];
> +	char dstbuf[33];
>  	uint64_t tmp = 0;
>  	int size;
>  
> -	memset(dstbuf, 0, 32);
> +	memset(dstbuf, 0, 33);
>  	size = (nbytes < 32) ? nbytes : 32;
>  	if (copy_from_user(dstbuf, buf, size))
>  		return 0;
> 

Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Martin K. Petersen Feb. 18, 2016, 12:17 a.m. UTC | #2
>>>>> "Alan" == Alan  <gnomes@lxorguk.ukuu.org.uk> writes:

Alan> If you feed 32 bytes in then the kstrtoull() doesn't receive a
Alan> terminated string so will run off the end.

Applied to 4.6/scsi-queue.
diff mbox

Patch

diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 25aa9b9..a63542b 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -1054,11 +1054,11 @@  lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf,
 {
 	struct dentry *dent = file->f_path.dentry;
 	struct lpfc_hba *phba = file->private_data;
-	char dstbuf[32];
+	char dstbuf[33];
 	uint64_t tmp = 0;
 	int size;
 
-	memset(dstbuf, 0, 32);
+	memset(dstbuf, 0, 33);
 	size = (nbytes < 32) ? nbytes : 32;
 	if (copy_from_user(dstbuf, buf, size))
 		return 0;