From: sashiko-bot@kernel.org
To: "Bart Van Assche" <bvanassche@acm.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 38/57] scsi: lpfc: Prepare for enabling lock context analysis
Date: Thu, 30 Jul 2026 23:09:31 +0000 [thread overview]
Message-ID: <20260730230931.A8AAE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <d7f69e9511ca5b79b64f48b1e54fb417db4d294f.1785451174.git.bvanassche@acm.org>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [High] An AB-BA lock inversion exists between `lpfc_cmd->buf_lock` and `phba->hbalock`, which can cause a hard deadlock.
- [High] Race condition in timer callback `lpfc_els_timeout_handler` leading to use-after-free on module unload.
- [High] List corruption due to missing lock protection for SLI ring lists in `lpfc_els_abort` and `lpfc_els_flush_cmd`.
- [High] Concurrent FCP abort requests will hang for the full timeout duration due to unshared wait queues.
--
--- Patch [38]: [PATCH v3 38/57] scsi: lpfc: Prepare for enabling lock context analysis ---
commit 7e811dc5ed08a4e45843970fc90d7859310944e2
Author: Bart Van Assche <bvanassche@acm.org>
scsi: lpfc: Prepare for enabling lock context analysis
Annotate the functions that perform conditional locking with
__context_unsafe().
> diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
> index 52fc5058976d9..45e7f147b1636 100644
> --- a/drivers/scsi/lpfc/lpfc_els.c
> +++ b/drivers/scsi/lpfc/lpfc_els.c
> @@ -9597,6 +9597,7 @@ lpfc_els_timeout(struct timer_list *t)
> **/
> void
> lpfc_els_timeout_handler(struct lpfc_vport *vport)
> + __context_unsafe(conditional locking)
> {
> struct lpfc_hba *phba = vport->phba;
[Severity: High]
This isn't a bug introduced by this patch, but is there a race condition
here during module unload?
Looking at the bottom of lpfc_els_timeout_handler(), the code checks for
FC_UNLOADING before calling mod_timer():
if (!test_bit(FC_UNLOADING, &phba->pport->load_flag))
mod_timer(&vport->els_tmofunc, ...);
If the teardown thread sets the FC_UNLOADING flag immediately after this
check is evaluated, the callback will re-arm the timer. Even if
timer_delete_sync() is used during teardown, the callback re-arms the timer
before exiting, which can cause the timer to fire on freed memory and lead
to a use-after-free crash.
> @@ -9719,6 +9720,7 @@ lpfc_els_timeout_handler(struct lpfc_vport *vport)
> **/
> void
> lpfc_els_flush_cmd(struct lpfc_vport *vport)
> + __context_unsafe(conditional locking)
> {
> LIST_HEAD(abort_list);
[Severity: High]
This is a pre-existing issue, but can list corruption occur here during ELS
command flushes?
In lpfc_els_flush_cmd(), this code moves piocb->list from txcmplq to
cancel_list:
spin_lock_irqsave(&phba->hbalock, iflags);
list_del_init(&piocb->dlist);
if (mbx_tmo_err || !(phba->sli.sli_flag & LPFC_SLI_ACTIVE))
list_move_tail(&piocb->list, &cancel_list);
For SLI4, is holding only hbalock sufficient, or does it also require
pring->ring_lock to safely modify the txcmplq, preventing kernel panics
during linked list traversal?
> diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
> index 9c449055a55e6..79e5e876c879e 100644
> --- a/drivers/scsi/lpfc/lpfc_nportdisc.c
> +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
> @@ -220,6 +220,7 @@ lpfc_check_elscmpl_iocb(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
> */
> void
> lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
> + __context_unsafe(conditional locking)
> {
> LIST_HEAD(abort_list);
[Severity: High]
This isn't a bug introduced by this patch, but does this list modification
lack lock protection?
In lpfc_els_abort(), list_del_init() modifies the active txcmplq without
holding any locks:
if (retval && test_bit(FC_UNLOADING, &phba->pport->load_flag)) {
list_del_init(&iocb->list);
list_add_tail(&iocb->list, &drv_cmpl_list);
}
Could this lead to list corruption during error recovery scenarios?
> diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
> index f2cab134af7f1..6c3fd3c33c535 100644
> --- a/drivers/scsi/lpfc/lpfc_scsi.c
> +++ b/drivers/scsi/lpfc/lpfc_scsi.c
> @@ -5520,6 +5520,7 @@ void lpfc_vmid_vport_cleanup(struct lpfc_vport *vport)
> **/
> static int
> lpfc_abort_handler(struct scsi_cmnd *cmnd)
> + __context_unsafe(conditional locking)
> {
> struct Scsi_Host *shost = cmnd->device->host;
[Severity: High]
This is a pre-existing issue, but does this locking order create an AB-BA
deadlock?
In lpfc_abort_handler(), lpfc_cmd->buf_lock is acquired followed by
phba->hbalock:
spin_lock_irqsave(&lpfc_cmd->buf_lock, flags);
spin_lock(&phba->hbalock);
In lpfc_sli_abort_taskmgmt(), the thread acquires phba->hbalock first,
iterates over commands, and attempts to acquire lpfc_cmd->buf_lock. Could
concurrent SCSI aborts and device resets freeze storage operations?
[Severity: High]
This is also a pre-existing issue, but can concurrent FCP abort requests
hang here?
In lpfc_abort_handler(), if a second thread attempts to abort the same
command, it detects LPFC_DRIVER_ABORTED and jumps to wait_for_cmpl:
wait_for_cmpl:
wait_event_timeout(waitq, (lpfc_cmd->pCmd != cmnd),
secs_to_jiffies(2*vport->cfg_devloss_tmo));
It then sleeps on its private, on-stack waitq. Because the completion
handler only knows about the first thread's wait queue, won't the second
thread block unconditionally for the full duration of the timeout?
> diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
> index 62a30a92b7927..c76d62e8907c1 100644
> --- a/drivers/scsi/lpfc/lpfc_sli.c
> +++ b/drivers/scsi/lpfc/lpfc_sli.c
[ ... ]
> @@ -12871,6 +12872,7 @@ lpfc_sli_abort_iocb(struct lpfc_vport *vport, u16 tgt_id, u64 lun_id,
> int
> lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring,
> uint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd cmd)
> + __context_unsafe(conditional locking)
> {
> struct lpfc_hba *phba = vport->phba;
[Severity: High]
This isn't a bug introduced by this patch, but as mentioned above, does this
lock ordering conflict with lpfc_abort_handler()?
In lpfc_sli_abort_taskmgmt(), phba->hbalock is acquired before
lpfc_cmd->buf_lock:
spin_lock_irqsave(&phba->hbalock, iflags);
...
lpfc_cmd = container_of(iocbq, struct lpfc_io_buf, cur_iocbq);
spin_lock(&lpfc_cmd->buf_lock);
This is the reverse of the order in lpfc_abort_handler(). Can this lead to
a hard deadlock during concurrent I/O timeouts?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1785451174.git.bvanassche@acm.org?part=38
next prev parent reply other threads:[~2026-07-30 23:09 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 22:44 [PATCH v3 00/57] Enable lock context analysis for the SCSI subsystem Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 01/57] PCI: Convert to_pci_dev() into an inline function Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 02/57] scsi: scsi_debug: Prepare for enabling lock context analysis Bart Van Assche
2026-07-30 23:01 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 03/57] scsi: sg: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 04/57] scsi: st: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 05/57] scsi: BusLogic: Introduce two local variables Bart Van Assche
2026-07-30 23:01 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 06/57] scsi: BusLogic: Prepare for enabling lock context analysis Bart Van Assche
2026-07-30 23:06 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 07/57] scsi: NCR5380: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 08/57] scsi: aacraid: " Bart Van Assche
2026-07-30 23:04 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 09/57] scsi: aic7xxx: Enable " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 10/57] scsi: aha152x: Prepare for enabling " Bart Van Assche
2026-07-30 23:18 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 11/57] scsi: aic7xxx: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 12/57] scsi: aic94xx: Enable " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 13/57] scsi: arcmsr: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 14/57] scsi: arm: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 15/57] scsi: be2iscsi: Prepare for enabling " Bart Van Assche
2026-07-30 23:04 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 16/57] scsi: be2iscsi: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 17/57] scsi: cxgbi: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 18/57] scsi: bfa: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 19/57] scsi: bnx2fc: " Bart Van Assche
2026-07-30 23:01 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 20/57] scsi: bnx2i: Introduce a local variable Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 21/57] scsi: bnx2i: Enable lock context analysis Bart Van Assche
2026-07-30 23:29 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 22/57] scsi: csiostor: " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 23/57] scsi: elx: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 24/57] scsi: esas2r: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 25/57] scsi: fcoe: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 26/57] scsi: fnic: " Bart Van Assche
2026-07-30 23:11 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 27/57] scsi: hisi_sas: " Bart Van Assche
2026-07-30 23:02 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 28/57] scsi: hpsa: Prepare for enabling " Bart Van Assche
2026-07-30 23:27 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 29/57] scsi: ibmvscsi: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 30/57] scsi: ibmvscsi_tgt: " Bart Van Assche
2026-07-30 23:27 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 31/57] scsi: ipr: Prepare for enabling " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 32/57] scsi: ips: " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 33/57] scsi: isci: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 34/57] scsi: libfc: " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 35/57] scsi: libiscsi: Prepare for enabling " Bart Van Assche
2026-07-30 23:17 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 36/57] scsi: libsas: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 37/57] scsi: libsas: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 38/57] scsi: lpfc: Prepare for enabling " Bart Van Assche
2026-07-30 23:09 ` sashiko-bot [this message]
2026-07-30 22:45 ` [PATCH v3 39/57] scsi: megaraid_sas: " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 40/57] scsi: megaraid: Enable " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 41/57] scsi: mpt3sas: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 42/57] scsi: mvsas: " Bart Van Assche
2026-07-30 23:18 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 43/57] scsi: pcmcia: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 44/57] scsi: pm8001: " Bart Van Assche
2026-07-30 23:31 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 45/57] scsi: qedf: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 46/57] scsi: qedi: " Bart Van Assche
2026-07-30 23:17 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 47/57] scsi: qla1280: Prepare for enabling " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 48/57] scsi: qla2xxx: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 49/57] scsi: qla4xxx: " Bart Van Assche
2026-07-30 23:25 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 50/57] scsi: ufs: " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 51/57] scsi: iSCSI transport: Prepare for enabling " Bart Van Assche
2026-07-30 23:23 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 52/57] scsi: smartpqi: Enable " Bart Van Assche
2026-07-30 23:22 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 53/57] scsi: snic: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 54/57] scsi: sym53c8xx_2: " Bart Van Assche
2026-07-30 23:27 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 55/57] scsi: core: Pass the SCSI host pointer directly Bart Van Assche
2026-07-30 23:22 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 56/57] scsi: core: Enable lock context analysis Bart Van Assche
2026-07-30 23:36 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 57/57] scsi: core: Protect host state changes with the host lock Bart Van Assche
2026-07-30 23:32 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260730230931.A8AAE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox