Skip to content

Commit 36d7991

Browse files
Justin Teevijay-suman
authored andcommitted
scsi: lpfc: Handle mailbox timeouts in lpfc_get_sfp_info
The MBX_TIMEOUT return code is not handled in lpfc_get_sfp_info and the routine unconditionally frees submitted mailbox commands regardless of return status. The issue is that for MBX_TIMEOUT cases, when firmware returns SFP information at a later time, that same mailbox memory region references previously freed memory in its cmpl routine. Fix by adding checks for the MBX_TIMEOUT return code. During mailbox resource cleanup, check the mbox flag to make sure that the wait did not timeout. If the MBOX_WAKE flag is not set, then do not free the resources because it will be freed when firmware completes the mailbox at a later time in its cmpl routine. Also, increase the timeout from 30 to 60 seconds to accommodate boot scripts requiring longer timeouts. Signed-off-by: Justin Tee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]> (cherry picked from commit ede596b) Orabug: 37116505 CVE: CVE-2024-46842 Signed-off-by: Himanshu Madhani <[email protected]> Reviewed-by: Harshit Mogalapalli <[email protected]> Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 713ec11 commit 36d7991

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/scsi/lpfc/lpfc_els.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7302,13 +7302,13 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
73027302
mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
73037303
}
73047304
mbox->vport = phba->pport;
7305-
7306-
rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30);
7305+
rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_SLI4_CONFIG_TMO);
73077306
if (rc == MBX_NOT_FINISHED) {
73087307
rc = 1;
73097308
goto error;
73107309
}
7311-
7310+
if (rc == MBX_TIMEOUT)
7311+
goto error;
73127312
if (phba->sli_rev == LPFC_SLI_REV4)
73137313
mp = mbox->ctx_buf;
73147314
else
@@ -7361,7 +7361,10 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
73617361
mbox->u.mqe.un.mem_dump_type3.addr_hi = putPaddrHigh(mp->phys);
73627362
}
73637363

7364-
rc = lpfc_sli_issue_mbox_wait(phba, mbox, 30);
7364+
rc = lpfc_sli_issue_mbox_wait(phba, mbox, LPFC_MBOX_SLI4_CONFIG_TMO);
7365+
7366+
if (rc == MBX_TIMEOUT)
7367+
goto error;
73657368
if (bf_get(lpfc_mqe_status, &mbox->u.mqe)) {
73667369
rc = 1;
73677370
goto error;
@@ -7372,8 +7375,10 @@ int lpfc_get_sfp_info_wait(struct lpfc_hba *phba,
73727375
DMP_SFF_PAGE_A2_SIZE);
73737376

73747377
error:
7375-
mbox->ctx_buf = mpsave;
7376-
lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
7378+
if (mbox->mbox_flag & LPFC_MBX_WAKE) {
7379+
mbox->ctx_buf = mpsave;
7380+
lpfc_mbox_rsrc_cleanup(phba, mbox, MBOX_THD_UNLOCKED);
7381+
}
73777382

73787383
return rc;
73797384

0 commit comments

Comments
 (0)