Skip to content

Commit e7b53f1

Browse files
committed
scsi: qla2xxx: Wait for io return on terminate rport
jira VULN-155086 cve CVE-2023-53322 commit-author Quinn Tran <qutran@marvell.com> commit fc0cba0 System crash due to use after free. Current code allows terminate_rport_io to exit before making sure all IOs has returned. For FCP-2 device, IO's can hang on in HW because driver has not tear down the session in FW at first sign of cable pull. When dev_loss_tmo timer pops, terminate_rport_io is called and upper layer is about to free various resources. Terminate_rport_io trigger qla to do the final cleanup, but the cleanup might not be fast enough where it leave qla still holding on to the same resource. Wait for IO's to return to upper layer before resources are freed. Cc: stable@vger.kernel.org Signed-off-by: Quinn Tran <qutran@marvell.com> Signed-off-by: Nilesh Javali <njavali@marvell.com> Link: https://lore.kernel.org/r/20230428075339.32551-7-njavali@marvell.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit fc0cba0) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 78e5c41 commit e7b53f1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/scsi/qla2xxx/qla_attr.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,6 +2639,7 @@ static void
26392639
qla2x00_terminate_rport_io(struct fc_rport *rport)
26402640
{
26412641
fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
2642+
scsi_qla_host_t *vha;
26422643

26432644
if (!fcport)
26442645
return;
@@ -2648,9 +2649,12 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
26482649

26492650
if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
26502651
return;
2652+
vha = fcport->vha;
26512653

26522654
if (unlikely(pci_channel_offline(fcport->vha->hw->pdev))) {
26532655
qla2x00_abort_all_cmds(fcport->vha, DID_NO_CONNECT << 16);
2656+
qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24,
2657+
0, WAIT_TARGET);
26542658
return;
26552659
}
26562660
/*
@@ -2672,6 +2676,15 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
26722676
qla2x00_port_logout(fcport->vha, fcport);
26732677
}
26742678
}
2679+
2680+
/* check for any straggling io left behind */
2681+
if (qla2x00_eh_wait_for_pending_commands(fcport->vha, fcport->d_id.b24, 0, WAIT_TARGET)) {
2682+
ql_log(ql_log_warn, vha, 0x300b,
2683+
"IO not return. Resetting. \n");
2684+
set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
2685+
qla2xxx_wake_dpc(vha);
2686+
qla2x00_wait_for_chip_reset(vha);
2687+
}
26752688
}
26762689

26772690
static int

0 commit comments

Comments
 (0)