Re: [PATCH v3] scsi: lpfc: Fix race conditions in ELS retry handling
From: Paul Ely
Date: Wed Nov 11 2026 - 09:52:29 EST
This patch addresses a race condition in the lpfc driver's ELS retry
event handling that can lead to a use-after-free in the
lpfc_cancel_retry_delay_tmo(), where the NLP_DELAY_TMO flag is cleared
before acquiring the lock to check if the retry event is queued. This
creates a window where the timer can be rescheduled and fire, causing
both the cancel path and the worker thread to release the same reference,
resulting in a double-put and use-after-free.
Moved capture ndlp and clear evt_arg1 under hbalock while dequeuing
LPFC_EVT_ELS_RETRY in lpfc_work_list_done().
Signed-off-by: Kyle Mahlkuch <kmahlkuc@xxxxxxxxxxxxx>
---
Changes since v2:
- Capture ndlp and clear evt_arg1 under hbalock while dequeuing
LPFC_EVT_ELS_RETRY in lpfc_work_list_done(). A requeue by
lpfc_els_retry_delay() could cause a NULL dereference in the worker.
(AI review)
- Whitespace and line-wrapping cleanup.
Hello Kyle, the patch would not apply. There is an extra space here
in lpfc_els.c:
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -4477,18 +4477,35 @@ lpfc_issue_els_edc(struct lpfc_vport *vport,
uint8_t retry)
void
lpfc_cancel_retry_delay_tmo(struct lpfc_vport *vport, struct
lpfc_nodelist *nlp)
{
- struct lpfc_work_evt *evtp;
+ struct lpfc_hba *phba = vport->phba;
+ struct lpfc_work_evt *evtp = &nlp->els_retry_evt;
+ struct lpfc_nodelist *arg_ndlp = NULL;
+ unsigned long flags;
<===== here
if (!test_and_clear_bit(NLP_DELAY_TMO, &nlp->nlp_flag))
return;
lpfc_hbadisc.c also has a white-space issue as well.
--ignore-whitespace allows the hunk. I looked quickly but didn't see
it.
The patch still looks good -
Paul
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature