Skip to content

Commit

Permalink
scsi: lpfc: Prevent buffer overflow crashes in debugfs with malformed…
Browse files Browse the repository at this point in the history
… user input

Malformed user input to debugfs results in buffer overflow crashes.  Adapt
input string lengths to fit within internal buffers, leaving space for NULL
terminators.

Link: https://lore.kernel.org/r/[email protected]
Co-developed-by: Justin Tee <[email protected]>
Signed-off-by: Justin Tee <[email protected]>
Signed-off-by: James Smart <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
  • Loading branch information
jsmart-gh authored and martinkpetersen committed Jul 7, 2022
1 parent 4ecc9b0 commit f8191d4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions drivers/scsi/lpfc/lpfc_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2607,8 +2607,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
struct lpfc_sli4_hdw_queue *qp;
struct lpfc_multixri_pool *multixri_pool;

if (nbytes > 64)
nbytes = 64;
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;

memset(mybuf, 0, sizeof(mybuf));

Expand Down Expand Up @@ -2688,8 +2688,8 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
if (!phba->targetport)
return -ENXIO;

if (nbytes > 64)
nbytes = 64;
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;

memset(mybuf, 0, sizeof(mybuf));

Expand Down Expand Up @@ -2826,8 +2826,8 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
char mybuf[64];
char *pbuf;

if (nbytes > 64)
nbytes = 64;
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;

memset(mybuf, 0, sizeof(mybuf));

Expand Down Expand Up @@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
char mybuf[64];
char *pbuf;

if (nbytes > 63)
nbytes = 63;
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;

memset(mybuf, 0, sizeof(mybuf));

Expand Down Expand Up @@ -3060,8 +3060,8 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
char *pbuf;
int i;

if (nbytes > 64)
nbytes = 64;
if (nbytes > sizeof(mybuf) - 1)
nbytes = sizeof(mybuf) - 1;

memset(mybuf, 0, sizeof(mybuf));

Expand Down

0 comments on commit f8191d4

Please sign in to comment.