scsi: qedi: Check for buffer overflow in qedi_set_path()
Subsystems (3)
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.
--- drivers/scsi/qedi/qedi_iscsi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/qedi/qedi_iscsi.c +4 -0
@@ -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
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 inqedi_set_path()External Email
----------------------------------------------------------------------
Smatch complains that the "path_data->handle" variable is user controlled. It comes fromiscsi_set_path()so that seems possible.
It's harmless to add a limit check.The qedi->ep_tbl[] array has
qedi->max_active_connselements (which is alwaysISCSI_MAX_SESS_PER_HBA(4096) elements). The array is allocated in theqedi_cm_alloc_mem()function.Fixes ace7f46ba5fd ("scsi: qedi: Add QLogic FastLinQ offload iSCSI driverframework.")
Signed-off-by Dan Carpenter <[email protected]>--- drivers/scsi/qedi/qedi_iscsi.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/scsi/qedi/qedi_iscsi.c +4
-0@@ -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,
Martin K. Petersen
AppliedQuoted 7 lines · Dan Carpenter
Smatch complains that the "
path_data->handle" variable is user controlled. It comes fromiscsi_set_path()so that seems possible. It's harmless to add a limit check.The qedi->ep_tbl[] array has
qedi->max_active_connselements (which is alwaysISCSI_MAX_SESS_PER_HBA(4096) elements). The array is allocated in theqedi_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