Skip to contentSkip to conversation

scsi: qedi: Check for buffer overflow in qedi_set_path()

PATCH Applied Dan Carpenter 3 participants 3 messages Apr 28, 2020 – Apr 30, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: qedi: Check for buffer overflow in qedi_set_path()

Smatch complains that the "path_data->handle" variable is user controlled. It comes from iscsi_set_path() so that seems possible. It's harmless to add a limit check.

The qedi->ep_tbl[] array has qedi->max_active_conns elements (which is always ISCSI_MAX_SESS_PER_HBA (4096) elements). The array is allocated in the qedi_cm_alloc_mem() function.

Fixes ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver framework.")
---
 drivers/scsi/qedi/qedi_iscsi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/qedi/qedi_iscsi.c +4 -0
index b867a143d2638..425e665ec08b2 100644
@@ -1221,6 +1221,10 @@ static int qedi_set_path(struct Scsi_Host *shost, struct iscsi_path *path_data)
 	}
 
 	iscsi_cid = (u32)path_data->handle;
+	if (iscsi_cid >= qedi->max_active_conns) {
+		ret = -EINVAL;
+		goto set_path_exit;
+	}
 	qedi_ep = qedi->ep_tbl[iscsi_cid];
 	QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
 		  "iscsi_cid=0x%x, qedi_ep=%p\n", iscsi_cid, qedi_ep);
Signature · 1 line
2.26.2
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 44 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Tuesday, April 28, 2020 6:50 PM
To: [email protected]; Manish Rangankar <[email protected]>
Cc: James E.J. Bottomley <[email protected]>; Martin K. Petersen <[email protected]>; [email protected]; kernel- [email protected]
Subject: [EXT] [PATCH] scsi: qedi: Check for buffer overflow in qedi_set_path()

External Email

----------------------------------------------------------------------
Smatch complains that the "path_data->handle" variable is user controlled. It comes from iscsi_set_path() so that seems possible.
It's harmless to add a limit check.

The qedi->ep_tbl[] array has qedi->max_active_conns elements (which is always ISCSI_MAX_SESS_PER_HBA (4096) elements). The array is allocated in the qedi_cm_alloc_mem() function.

Fixes ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driver

framework.")

---
 drivers/scsi/qedi/qedi_iscsi.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/qedi/qedi_iscsi.c +4 -0
index b867a143d2638..425e665ec08b2 100644
@@ -1221,6 +1221,10 @@ static int qedi_set_path(struct Scsi_Host
 *shost, struct iscsi_path *path_data)
 	}
 
 	iscsi_cid = (u32)path_data->handle;
+	if (iscsi_cid >= qedi->max_active_conns) {
+		ret = -EINVAL;
+		goto set_path_exit;
+	}
 	qedi_ep = qedi->ep_tbl[iscsi_cid];
 	QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
Quoted 1 line

"iscsi_cid=0x%x, qedi_ep=%p\n", iscsi_cid, qedi_ep);

Thanks,

#2 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter

Smatch complains that the "path_data->handle" variable is user controlled. It comes from iscsi_set_path() so that seems possible. It's harmless to add a limit check.

The qedi->ep_tbl[] array has qedi->max_active_conns elements (which is always ISCSI_MAX_SESS_PER_HBA (4096) elements). The array is allocated in the qedi_cm_alloc_mem() function.

Applied to 5.8/scsi-queue, thanks!

[1/1] scsi: qedi: Check for buffer overflow in qedi_set_path()

      https://git.kernel.org/mkp/scsi/c/4a4c0cfb4be7
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering