History

scsi: lpfc: Resolve NULL ptr dereference after an ELS LOGO is aborted

A use-after-free crash can occur after an ELS LOGO is aborted. Specifically, a nodelist structure is freed and then ndlp->vport->cfg_log_verbose is dereferenced in lpfc_nlp_get() when the discovery state machine is mistakenly called a second time with NLP_EVT_DEVICE_RM argument. Rework lpfc_cmpl_els_logo() to prevent the duplicate calls to release a nodelist structure.

James Smart committed 4 years ago

Commit b1b34401 parent 6f808bd1 file · +9 −12Browse files

Unified · Split

drivers/scsi/lpfc/lpfc_els.c+9−12
@@ -2998,10 +2998,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 2997 unmodified lines
29982998 ndlp->nlp_DID, ulp_status,
29992999 ulp_word4);
30003000
3001− /* Call NLP_EVT_DEVICE_RM if link is down or LOGO is aborted */
30023001 if (lpfc_error_lost_link(ulp_status, ulp_word4)) {
3003− lpfc_disc_state_machine(vport, ndlp, cmdiocb,
3004− NLP_EVT_DEVICE_RM);
30053002 skip_recovery = 1;
30063003 goto out;
30073004 }
@@ -3021,18 +3018,10 @@ lpfc_cmpl_els_logo(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, · 13 unmodified lines
30213018 spin_unlock_irq(&ndlp->lock);
30223019 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
30233020 NLP_EVT_DEVICE_RM);
3024− lpfc_els_free_iocb(phba, cmdiocb);
3025− lpfc_nlp_put(ndlp);
3026−
3027− /* Presume the node was released. */
3028− return;
3021+ goto out_rsrc_free;
30293022 }
30303023
30313024 out:
3032− /* Driver is done with the IO. */
3033− lpfc_els_free_iocb(phba, cmdiocb);
3034− lpfc_nlp_put(ndlp);
3035−
30363025 /* At this point, the LOGO processing is complete. NOTE: For a
30373026 * pt2pt topology, we are assuming the NPortID will only change
30383027 * on link up processing. For a LOGO / PLOGI initiated by the
@@ -3059,6 +3048,10 @@ out: · 20 unmodified lines
30593048 ndlp->nlp_DID, ulp_status,
30603049 ulp_word4, tmo,
30613050 vport->num_disc_nodes);
3051+
3052+ lpfc_els_free_iocb(phba, cmdiocb);
3053+ lpfc_nlp_put(ndlp);
3054+
30623055 lpfc_disc_start(vport);
30633056 return;
30643057 }
@@ -3075,6 +3068,10 @@ out: · 10 unmodified lines
30753068 lpfc_disc_state_machine(vport, ndlp, cmdiocb,
30763069 NLP_EVT_DEVICE_RM);
30773070 }
3071+out_rsrc_free:
3072+ /* Driver is done with the I/O. */
3073+ lpfc_els_free_iocb(phba, cmdiocb);
3074+ lpfc_nlp_put(ndlp);
30783075 }
30793076
30803077 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t