|
Daniel Wagner |
626092 |
From: James Smart <jsmart2021@gmail.com>
|
|
Daniel Wagner |
626092 |
Date: Fri, 3 Jun 2022 10:43:25 -0700
|
|
Daniel Wagner |
626092 |
Subject: scsi: lpfc: Resolve NULL ptr dereference after an ELS LOGO is aborted
|
|
Daniel Wagner |
626092 |
Patch-mainline: v5.19-rc2
|
|
Daniel Wagner |
626092 |
Git-commit: b1b3440f437b75fb2a9b0cfe58df461e40eca474
|
|
Daniel Wagner |
626092 |
References: bsc#1201193
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
A use-after-free crash can occur after an ELS LOGO is aborted.
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
Specifically, a nodelist structure is freed and then
|
|
Daniel Wagner |
626092 |
ndlp->vport->cfg_log_verbose is dereferenced in lpfc_nlp_get() when the
|
|
Daniel Wagner |
626092 |
discovery state machine is mistakenly called a second time with
|
|
Daniel Wagner |
626092 |
NLP_EVT_DEVICE_RM argument.
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
Rework lpfc_cmpl_els_logo() to prevent the duplicate calls to release a
|
|
Daniel Wagner |
626092 |
nodelist structure.
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
Link: https://lore.kernel.org/r/20220603174329.63777-6-jsmart2021@gmail.com
|
|
Daniel Wagner |
626092 |
Co-developed-by: Justin Tee <justin.tee@broadcom.com>
|
|
Daniel Wagner |
626092 |
Signed-off-by: Justin Tee <justin.tee@broadcom.com>
|
|
Daniel Wagner |
626092 |
Signed-off-by: James Smart <jsmart2021@gmail.com>
|
|
Daniel Wagner |
626092 |
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
|
|
Daniel Wagner |
626092 |
Acked-by: Daniel Wagner <dwagner@suse.de>
|
|
Daniel Wagner |
626092 |
---
|
|
Daniel Wagner |
626092 |
drivers/scsi/lpfc/lpfc_els.c | 21 +++++++++------------
|
|
Daniel Wagner |
626092 |
1 file changed, 9 insertions(+), 12 deletions(-)
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
--- a/drivers/scsi/lpfc/lpfc_els.c
|
|
Daniel Wagner |
626092 |
+++ b/drivers/scsi/lpfc/lpfc_els.c
|
|
Daniel Wagner |
626092 |
@@ -2998,10 +2998,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba
|
|
Daniel Wagner |
626092 |
ndlp->nlp_DID, ulp_status,
|
|
Daniel Wagner |
626092 |
ulp_word4);
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
- /* Call NLP_EVT_DEVICE_RM if link is down or LOGO is aborted */
|
|
Daniel Wagner |
626092 |
if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
|
|
Daniel Wagner |
626092 |
- lpfc_disc_state_machine(vport, ndlp, cmdiocb,
|
|
Daniel Wagner |
626092 |
- NLP_EVT_DEVICE_RM);
|
|
Daniel Wagner |
626092 |
skip_recovery = 1;
|
|
Daniel Wagner |
626092 |
goto out;
|
|
Daniel Wagner |
626092 |
}
|
|
Daniel Wagner |
626092 |
@@ -3021,18 +3018,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba
|
|
Daniel Wagner |
626092 |
spin_unlock_irq(&ndlp->lock);
|
|
Daniel Wagner |
626092 |
lpfc_disc_state_machine(vport, ndlp, cmdiocb,
|
|
Daniel Wagner |
626092 |
NLP_EVT_DEVICE_RM);
|
|
Daniel Wagner |
626092 |
- lpfc_els_free_iocb(phba, cmdiocb);
|
|
Daniel Wagner |
626092 |
- lpfc_nlp_put(ndlp);
|
|
Daniel Wagner |
626092 |
-
|
|
Daniel Wagner |
626092 |
- /* Presume the node was released. */
|
|
Daniel Wagner |
626092 |
- return;
|
|
Daniel Wagner |
626092 |
+ goto out_rsrc_free;
|
|
Daniel Wagner |
626092 |
}
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
out:
|
|
Daniel Wagner |
626092 |
- /* Driver is done with the IO. */
|
|
Daniel Wagner |
626092 |
- lpfc_els_free_iocb(phba, cmdiocb);
|
|
Daniel Wagner |
626092 |
- lpfc_nlp_put(ndlp);
|
|
Daniel Wagner |
626092 |
-
|
|
Daniel Wagner |
626092 |
/* At this point, the LOGO processing is complete. NOTE: For a
|
|
Daniel Wagner |
626092 |
* pt2pt topology, we are assuming the NPortID will only change
|
|
Daniel Wagner |
626092 |
* on link up processing. For a LOGO / PLOGI initiated by the
|
|
Daniel Wagner |
626092 |
@@ -3059,6 +3048,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba
|
|
Daniel Wagner |
626092 |
ndlp->nlp_DID, ulp_status,
|
|
Daniel Wagner |
626092 |
ulp_word4, tmo,
|
|
Daniel Wagner |
626092 |
vport->num_disc_nodes);
|
|
Daniel Wagner |
626092 |
+
|
|
Daniel Wagner |
626092 |
+ lpfc_els_free_iocb(phba, cmdiocb);
|
|
Daniel Wagner |
626092 |
+ lpfc_nlp_put(ndlp);
|
|
Daniel Wagner |
626092 |
+
|
|
Daniel Wagner |
626092 |
lpfc_disc_start(vport);
|
|
Daniel Wagner |
626092 |
return;
|
|
Daniel Wagner |
626092 |
}
|
|
Daniel Wagner |
626092 |
@@ -3075,6 +3068,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba
|
|
Daniel Wagner |
626092 |
lpfc_disc_state_machine(vport, ndlp, cmdiocb,
|
|
Daniel Wagner |
626092 |
NLP_EVT_DEVICE_RM);
|
|
Daniel Wagner |
626092 |
}
|
|
Daniel Wagner |
626092 |
+out_rsrc_free:
|
|
Daniel Wagner |
626092 |
+ /* Driver is done with the I/O. */
|
|
Daniel Wagner |
626092 |
+ lpfc_els_free_iocb(phba, cmdiocb);
|
|
Daniel Wagner |
626092 |
+ lpfc_nlp_put(ndlp);
|
|
Daniel Wagner |
626092 |
}
|
|
Daniel Wagner |
626092 |
|
|
Daniel Wagner |
626092 |
/**
|