From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: James Smart <jsmart2021@gmail.com>, Justin Tee <justin.tee@broadcom.com>
Subject: [PATCH 02/12] lpfc: Prevent buffer overflow crashes in debugfs with malformed user input
Date: Fri, 1 Jul 2022 14:14:15 -0700 [thread overview]
Message-ID: <20220701211425.2708-3-jsmart2021@gmail.com> (raw)
In-Reply-To: <20220701211425.2708-1-jsmart2021@gmail.com>
Malformed user input to debugfs results in buffer overflow crashes.
Adapt input string lengths to fit within internal buffers, leaving
space for NULL terminators.
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>
---
drivers/scsi/lpfc/lpfc_debugfs.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
index 7b24c932e812..25deacc92b02 100644
--- a/drivers/scsi/lpfc/lpfc_debugfs.c
+++ b/drivers/scsi/lpfc/lpfc_debugfs.c
@@ -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));
@@ -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));
@@ -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));
@@ -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));
@@ -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));
--
2.26.2
next prev parent reply other threads:[~2022-07-01 21:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 21:14 [PATCH 00/12] lpfc: Update lpfc to revision 14.2.0.5 James Smart
2022-07-01 21:14 ` [PATCH 01/12] lpfc: Fix uninitialized cqe field in lpfc_nvme_cancel_iocb James Smart
2022-07-01 21:14 ` James Smart [this message]
2022-07-01 21:14 ` [PATCH 03/12] lpfc: Set PU field when providing D_ID in XMIT_ELS_RSP64_CX iocb James Smart
2022-07-01 21:14 ` [PATCH 04/12] lpfc: Remove extra atomic_inc on cmd_pending in queuecommand after VMID James Smart
2022-07-01 21:14 ` [PATCH 05/12] lpfc: Fix possible memory leak when failing to issue CMF WQE James Smart
2022-07-01 21:14 ` [PATCH 06/12] lpfc: Fix attempted FA-PWWN usage after feature disable James Smart
2022-07-01 21:14 ` [PATCH 07/12] lpfc: Fix lost NVME paths during LIF bounce stress test James Smart
2022-07-01 21:14 ` [PATCH 08/12] lpfc: Revert RSCN_MEMENTO workaround for misbehaved configuration James Smart
2022-07-01 21:14 ` [PATCH 09/12] lpfc: Refactor lpfc_nvmet_prep_abort_wqe into lpfc_sli_prep_abort_xri James Smart
2022-07-01 21:14 ` [PATCH 10/12] lpfc: Remove Menlo/Hornet related code James Smart
2022-07-01 21:14 ` [PATCH 11/12] lpfc: Update lpfc version to 14.2.0.5 James Smart
2022-07-01 21:14 ` [PATCH 12/12] lpfc: Copyright updates for 14.2.0.5 patches James Smart
2022-07-07 21:17 ` [PATCH 00/12] lpfc: Update lpfc to revision 14.2.0.5 Martin K. Petersen
2022-07-14 4:22 ` Martin K. Petersen
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=20220701211425.2708-3-jsmart2021@gmail.com \
--to=jsmart2021@gmail.com \
--cc=justin.tee@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
/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