Skip to contentSkip to conversation

lpfc: fix missing zero termination in debugfs

PATCH Applied Alan 3 participants 3 messages Feb 15, 2016 – Feb 18, 2016

Subsystems (2)
lore
Share & tools
lore

Alan

author
#0 lore raw

PATCH 1/1 lpfc: fix missing zero termination in debugfs

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

---
 drivers/scsi/lpfc/lpfc_debugfs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +2 -2
index 25aa9b9..a63542b 100644
@@ -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 on v1 1/1
#1 lore raw
Quoted 17 lines · Alan

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

---
 drivers/scsi/lpfc/lpfc_debugfs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/lpfc/lpfc_debugfs.c +0 -0
index 25aa9b9..a63542b 100644
@@ -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;

drivers/scsi/lpfc/lpfc_debugfs.c lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, · line 1064

Quoted 10 lines
drivers/scsi/lpfc/lpfc_debugfs.c +2 -2
-	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;
Signature · 10 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
In reply to Alan
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Alan" == Alan <[email protected]> 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.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering