From: sashiko-bot@kernel.org
To: "Nigel Kirkland" <nkirkland2304@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 2/8] lpfc: Early return out of lpfc_els_abort when HBA_SETUP flag is not set
Date: Tue, 13 Oct 2026 00:05:25 +0000 [thread overview]
Message-ID: <sashiko-outbox-168769@kernel.org> (raw)
In-Reply-To: <20261013001648.62289-3-nkirkland2304@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: lpfc: lockless HBA_SETUP check leaves TOCTOU Use-After-Free race on pring
--
commit b6474390ac6cffa345174f9e11e10a15b8a091a7
Author: Nigel Kirkland <nkirkland2304@gmail.com>
lpfc: Early return out of lpfc_els_abort when HBA_SETUP flag is not set
This commit adds an early check on the HBA_SETUP flag in lpfc_els_abort()
to avoid using a stale ELS pring pointer during an HBA reset.
> diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
> index 9c449055a55e6..2c8d995a45bf8 100644
> --- a/drivers/scsi/lpfc/lpfc_nportdisc.c
> +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
> @@ -227,6 +227,11 @@ lpfc_els_abort(struct lpfc_hba *phba, struct lpfc_nodelist *ndlp)
> struct lpfc_iocbq *iocb, *next_iocb;
> int retval = 0;
>
> + /* Exit early to prevent race with queue teardown. */
> + if (unlikely(phba->sli_rev == LPFC_SLI_REV4 &&
> + !test_bit(HBA_SETUP, &phba->hba_flag)))
> + return;
> +
[Severity: High]
Does this lockless check leave a time-of-check to time-of-use race window
that can still result in a use-after-free on the pring pointer?
If a dev_loss_tmo callback executing lpfc_els_abort() is running
concurrently with an HBA reset, could this sequence occur:
CPU1 (dev_loss_tmo)
lpfc_els_abort()
test_bit(HBA_SETUP, &phba->hba_flag) // returns true
pring = lpfc_phba_elsring(phba);
CPU2 (HBA reset)
lpfc_sli_brdrestart_s4()
clear_bit(HBA_SETUP, &phba->hba_flag);
lpfc_sli4_queue_unset(phba);
lpfc_wq_destroy(wq);
kfree(wq->pring);
CPU1
spin_lock_irq(&phba->hbalock);
spin_lock(&pring->ring_lock); // use-after-free on stale pring pointer
Should the check and the subsequent usage of pring be synchronized against
the queue teardown path?
> pring = lpfc_phba_elsring(phba);
>
> /* In case of error recovery path, we might have a NULL pring here */
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013001648.62289-1-nkirkland2304@gmail.com?part=2
next prev parent reply other threads:[~2026-10-13 0:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 0:16 [PATCH v6 0/8] lpfc: Update lpfc to revision 15.0.0.1 Nigel Kirkland
2026-10-13 0:16 ` [PATCH v6 1/8] lpfc: Fix use-after-free in lpfc_cmpl_ct_cmd_vmid Nigel Kirkland
2026-10-13 0:03 ` sashiko-bot
2026-10-13 0:16 ` [PATCH v6 2/8] lpfc: Early return out of lpfc_els_abort when HBA_SETUP flag is not set Nigel Kirkland
2026-10-13 0:05 ` sashiko-bot [this message]
2026-10-13 0:16 ` [PATCH v6 3/8] lpfc: Fix kernel oops when unmapping scsi dma buffers for an aborted cmd Nigel Kirkland
2026-10-13 0:07 ` sashiko-bot
2026-10-13 0:16 ` [PATCH v6 4/8] lpfc: Check fc4_xpt_flags before decrementing ndlp kref on FDISC error Nigel Kirkland
2026-10-13 0:16 ` [PATCH v6 5/8] lpfc: Rework I/O flush ordering when unloading driver Nigel Kirkland
2026-10-13 0:12 ` sashiko-bot
2026-10-13 0:16 ` [PATCH v6 6/8] lpfc: Refactor calls on fc_disctmo to lpfc_set_disctmo in RSCN handler Nigel Kirkland
2026-10-13 0:16 ` [PATCH v6 7/8] lpfc: Update correct ndlp refcnt when rejecting an unsolicited PLOGI Nigel Kirkland
2026-10-13 0:13 ` sashiko-bot
2026-10-13 0:16 ` [PATCH v6 8/8] lpfc: Update lpfc version to 15.0.0.1 Nigel Kirkland
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=sashiko-outbox-168769@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=nkirkland2304@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.