Skip to content

Commit 8aed17c

Browse files
committed
scsi: lpfc: Prevent buffer overflow crashes in debugfs with malformed user input
jira VULN-70476 cve CVE-2022-50030 commit-author James Smart <jsmart2021@gmail.com> commit f8191d4 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/20220701211425.2708-3-jsmart2021@gmail.com Co-developed-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: Justin Tee <justin.tee@broadcom.com> Signed-off-by: James Smart <jsmart2021@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit f8191d4) Signed-off-by: Roxana Nicolescu <rnicolescu@ciq.com>
1 parent 381e878 commit 8aed17c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,8 +2607,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
26072607
struct lpfc_sli4_hdw_queue *qp;
26082608
struct lpfc_multixri_pool *multixri_pool;
26092609

2610-
if (nbytes > 64)
2611-
nbytes = 64;
2610+
if (nbytes > sizeof(mybuf) - 1)
2611+
nbytes = sizeof(mybuf) - 1;
26122612

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

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

2691-
if (nbytes > 64)
2692-
nbytes = 64;
2691+
if (nbytes > sizeof(mybuf) - 1)
2692+
nbytes = sizeof(mybuf) - 1;
26932693

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

@@ -2826,8 +2826,8 @@ lpfc_debugfs_ioktime_write(struct file *file, const char __user *buf,
28262826
char mybuf[64];
28272827
char *pbuf;
28282828

2829-
if (nbytes > 64)
2830-
nbytes = 64;
2829+
if (nbytes > sizeof(mybuf) - 1)
2830+
nbytes = sizeof(mybuf) - 1;
28312831

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

@@ -2954,8 +2954,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
29542954
char mybuf[64];
29552955
char *pbuf;
29562956

2957-
if (nbytes > 63)
2958-
nbytes = 63;
2957+
if (nbytes > sizeof(mybuf) - 1)
2958+
nbytes = sizeof(mybuf) - 1;
29592959

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

@@ -3060,8 +3060,8 @@ lpfc_debugfs_hdwqstat_write(struct file *file, const char __user *buf,
30603060
char *pbuf;
30613061
int i;
30623062

3063-
if (nbytes > 64)
3064-
nbytes = 64;
3063+
if (nbytes > sizeof(mybuf) - 1)
3064+
nbytes = sizeof(mybuf) - 1;
30653065

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

0 commit comments

Comments
 (0)