From: Praneeth Balasubramanian <praneethb2002@gmail.com>
To: Satish Kharat <satishkh@cisco.com>,
Sesidhar Baddela <sebaddel@cisco.com>,
Karan Tilak Kumar <kartilak@cisco.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>
Cc: Praneeth Balasubramanian <praneethb2002@gmail.com>,
stable@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 7/9] scsi: fnic: Hold fnic_lock for the oxid calls in the FIP timer work
Date: Fri, 4 Dec 2026 22:32:27 -0800 [thread overview]
Message-ID: <20261205063229.2518424-8-praneethb2002@gmail.com> (raw)
In-Reply-To: <20261205063229.2518424-1-praneethb2002@gmail.com>
fdls_alloc_oxid() and fdls_schedule_oxid_free() must be called with
fnic->fnic_lock held. Both assert it with lockdep_assert_held(). The
oxid bitmap and the oxid reclaim list they update are also changed by
fdls_reclaim_oxid_handler() and by the frame receive path, which hold
the lock.
fnic_work_on_fip_timer() runs on fnic_fip_queue without the lock. On a
FLOGI timeout it calls fdls_schedule_oxid_free(), and through
fnic_fcoe_start_flogi() it calls fdls_alloc_oxid(). With lockdep
enabled, both calls trigger the assertion. Without lockdep, the list_add
can race with the list_del and kfree in the reclaim handler.
Take fnic_lock around the two calls. The rest of the timer work is left
as it is: fnic_vlan_discovery_timeout() takes the lock itself, and the
frame send does not need it.
This was found by an LLM-based audit that checks code against the rules
stated in kernel comments.
Fixes: 098585aa8aca ("scsi: fnic: Add and integrate support for FIP")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>
---
Notes:
This was found by an LLM-based audit, part of research at UCSB SecLab.
An LLM turned a kernel comment into a rule, and three LLM votes checked
the code against it. The fix and changelog were drafted with GLM-5.3,
then checked against the source and partly rewritten with Claude Opus
5.5. I reviewed the patch and take responsibility for it.
Testing: builds without new warnings with W=1 (x86_64 allmodconfig),
clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no
reproducer. I do not have this hardware.
drivers/scsi/fnic/fip.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/scsi/fnic/fip.c b/drivers/scsi/fnic/fip.c
index 8f44abfc01a5..e9d4fe9777ab 100644
--- a/drivers/scsi/fnic/fip.c
+++ b/drivers/scsi/fnic/fip.c
@@ -353,6 +353,7 @@ void fnic_fcoe_start_flogi(struct fnic *fnic)
u64 flogi_tov;
uint16_t oxid;
uint16_t frame_size = sizeof(struct fip_flogi);
+ unsigned long flags;
frame = fdls_alloc_frame(iport);
if (frame == NULL) {
@@ -406,8 +407,10 @@ void fnic_fcoe_start_flogi(struct fnic *fnic)
memcpy(pflogi_req->eth.h_dest, iport->selected_fcf.fcf_mac,
ETH_ALEN);
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
oxid = fdls_alloc_oxid(iport, FNIC_FRAME_TYPE_FABRIC_FLOGI,
&iport->active_oxid_fabric_req);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
if (oxid == FNIC_UNASSIGNED_OXID) {
FNIC_FCS_DBG(KERN_INFO, fnic,
"Failed to allocate OXID to send FIP FLOGI");
@@ -752,7 +755,11 @@ void fnic_work_on_fip_timer(struct work_struct *work)
fnic_vlan_discovery_timeout(fnic);
}
} else if (iport->fip.state == FDLS_FIP_FLOGI_STARTED) {
+ unsigned long flags;
+
+ spin_lock_irqsave(&fnic->fnic_lock, flags);
fdls_schedule_oxid_free(iport, &iport->active_oxid_fabric_req);
+ spin_unlock_irqrestore(&fnic->fnic_lock, flags);
FNIC_FIP_DBG(KERN_INFO, fnic,
"FLOGI timeout\n");
if (iport->fip.flogi_retry < fnic->config.flogi_retries)
--
2.25.1
next prev parent reply other threads:[~2026-12-05 6:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 6:32 [PATCH 0/9] scsi: fix missing locking and dump length checks in several drivers Praneeth Balasubramanian
2026-12-05 6:32 ` [PATCH 1/9] scsi: bnx2i: Hold the session back_lock around iscsi_itt_to_task() Praneeth Balasubramanian
2026-12-05 6:32 ` [PATCH 2/9] scsi: mpt3sas: do not keep an enclosure pointer across a host reset Praneeth Balasubramanian
2026-12-05 6:46 ` sashiko-bot
2026-12-05 6:32 ` [PATCH 3/9] scsi: pmcraid: Take host_lock around scsi_report_bus_reset() Praneeth Balasubramanian
2026-12-05 6:43 ` sashiko-bot
2026-12-05 8:20 ` Praneeth Balasubramanian
2026-12-05 6:32 ` [PATCH 4/9] scsi: ipr: Skip dump entries whose length is not a 4 byte multiple Praneeth Balasubramanian
2026-12-05 6:32 ` [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler Praneeth Balasubramanian
2026-12-05 6:50 ` sashiko-bot
2026-12-05 8:20 ` Praneeth Balasubramanian
2026-12-05 6:32 ` [PATCH 6/9] scsi: csiostor: hold hw lock when issuing port stats mailbox command Praneeth Balasubramanian
2026-12-05 6:47 ` sashiko-bot
2026-12-05 8:20 ` Praneeth Balasubramanian
2026-12-05 6:32 ` Praneeth Balasubramanian [this message]
2026-12-05 6:32 ` [PATCH 8/9] scsi: qla2xxx: Hold qp_lock when completing command in abort timeout Praneeth Balasubramanian
2026-12-05 6:58 ` sashiko-bot
2026-12-05 6:32 ` [PATCH 9/9] scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE Praneeth Balasubramanian
2026-12-05 6:56 ` 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=20261205063229.2518424-8-praneethb2002@gmail.com \
--to=praneethb2002@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=kartilak@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=satishkh@cisco.com \
--cc=sebaddel@cisco.com \
--cc=stable@vger.kernel.org \
/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.