Skip to content

Commit 69a3a7b

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Fix memory overwrite during FC-GS I/O abort handling
When an FC-GS I/O is aborted by lpfc, the driver requires a node pointer for a dereference operation. In the abort I/O routine, the driver miscasts a context pointer to the wrong data type and overwrites a single byte outside of the allocated space. This miscast is done in the abort I/O function handler because the handler works on both FC-GS and FC-LS commands. However, the code neglected to get the correct job location for the node. Fix this by acquiring the necessary node pointer from the correct job structure depending on the I/O type. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent a013c71 commit 69a3a7b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12292,23 +12292,26 @@ void
1229212292
lpfc_ignore_els_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
1229312293
struct lpfc_iocbq *rspiocb)
1229412294
{
12295-
struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
12295+
struct lpfc_nodelist *ndlp = NULL;
1229612296
IOCB_t *irsp = &rspiocb->iocb;
1229712297

1229812298
/* ELS cmd tag <ulpIoTag> completes */
1229912299
lpfc_printf_log(phba, KERN_INFO, LOG_ELS,
12300-
"0139 Ignoring ELS cmd tag x%x completion Data: "
12300+
"0139 Ignoring ELS cmd code x%x completion Data: "
1230112301
"x%x x%x x%x\n",
1230212302
irsp->ulpIoTag, irsp->ulpStatus,
1230312303
irsp->un.ulpWord[4], irsp->ulpTimeout);
1230412304
/*
1230512305
* Deref the ndlp after free_iocb. sli_release_iocb will access the ndlp
1230612306
* if exchange is busy.
1230712307
*/
12308-
if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR)
12308+
if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) {
12309+
ndlp = cmdiocb->context_un.ndlp;
1230912310
lpfc_ct_free_iocb(phba, cmdiocb);
12310-
else
12311+
} else {
12312+
ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
1231112313
lpfc_els_free_iocb(phba, cmdiocb);
12314+
}
1231212315

1231312316
lpfc_nlp_put(ndlp);
1231412317
}

0 commit comments

Comments
 (0)