From: sashiko-bot@kernel.org
To: "Karan Tilak Kumar" <kartilak@cisco.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests
Date: Wed, 24 Jun 2026 05:13:31 +0000 [thread overview]
Message-ID: <20260624051331.AEF7C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260624044334.3079-11-kartilak@cisco.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Critical] Data Race / List Corruption and Use-After-Free due to incorrectly dropping fnic_lock before sending ABTS.
Pre-existing issues:
- [High] Use-After-Free in the timer callback due to missing timer_delete_sync() before freeing memory.
--
commit da372c5b4e5660f32542c6cb182b777f4f2e3531
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Abort timed-out NVMe LS requests
Add an FDLS helper that sends ABTS frames for outstanding NVMe LS
requests. Use the active LS request OXID when building the ABTS frame,
send it through the FCoE transmit path, and call it from LS timeout
and abort handling.
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> index 16e2f0add5ce6..c4de6606c0b2f 100644
> --- a/drivers/scsi/fnic/fnic_nvme.c
> +++ b/drivers/scsi/fnic/fnic_nvme.c
[ ... ]
> @@ -1248,6 +1252,23 @@ void nvfnic_ls_rsp_recv(struct fnic_iport_s *iport,
> spin_lock_irqsave(&fnic->fnic_lock, fnic->lock_flags);
> }
[Severity: High]
This isn't a bug introduced by this patch, but does the timer cancellation in
nvfnic_ls_rsp_recv() have a use-after-free race with the timer callback?
In nvfnic_ls_rsp_recv(), the code calls the non-synchronous timer_delete():
timer_delete(&nvfnic_ls_req->ls_req_timer);
...
spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
lsreq->done(lsreq, status);
Because timer_delete() doesn't wait for the timer callback to finish on other
CPUs, if nvfnic_ls_req_timeout() is concurrently executing and spinning to
acquire fnic_lock, couldn't the lock be dropped here, allowing lsreq->done()
to immediately free the memory, while the timer callback proceeds to access it?
[ ... ]
> @@ -1290,6 +1310,19 @@ void nvfnic_ls_req_timeout(struct timer_list *t)
> FNIC_NVME_DBG(KERN_ERR, fnic,
> "tport: 0x%x lsreq: 0x%x sending abort\n",
> tport->fcid, nvfnic_ls_req->oxid);
> + nvfnic_ls_req->state = FNIC_LS_REQ_CMD_ABTS_PENDING;
> + spin_unlock_irqrestore(&fnic->fnic_lock, fnic->lock_flags);
> +
> + if (fdls_send_ls_req_abts(iport, tport, nvfnic_ls_req->oxid) == 0) {
[Severity: Critical]
Does dropping fnic_lock here before calling fdls_send_ls_req_abts() expose the
driver to list corruption?
fdls_send_ls_req_abts() calls fnic_send_fcoe_frame(), which eventually calls
fdls_send_fcoe_frame(). That function appears to perform a lockless
list_add_tail(&frame_elem->links, &fnic->tx_queue), relying on the caller
to hold fnic_lock.
Additionally, does dropping the lock here expose the tport pointer to
concurrent deletion, potentially causing a use-after-free?
> + timeout = FNIC_LS_REQ_TMO_MSECS(ls_req->timeout);
> + mod_timer(&nvfnic_ls_req->ls_req_timer,
> + round_jiffies(jiffies + msecs_to_jiffies(timeout)));
> + return;
> + }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=10
next prev parent reply other threads:[~2026-06-24 5:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 4:43 [PATCH v5 00/13] Introduce functionality for NVMe initiator Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 01/13] scsi: fnic: Make debug logging protocol independent Karan Tilak Kumar
2026-06-24 5:08 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 02/13] scsi: fnic: Use fnic_num for non-SCSI identifiers Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 03/13] scsi: fnic: Decode firmware role configuration Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 04/13] scsi: fnic: Advertise NVMe initiator service parameters Karan Tilak Kumar
2026-06-24 4:43 ` [PATCH v5 05/13] scsi: fnic: Add FDLS role handling for NVMe initiators Karan Tilak Kumar
2026-06-24 5:18 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 06/13] scsi: fnic: Add the NVMe/FC transport path Karan Tilak Kumar
2026-06-24 5:12 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 07/13] scsi: fnic: Route completions and resets by initiator role Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 08/13] scsi: fnic: Handle NVMe LS frames in FDLS Karan Tilak Kumar
2026-06-24 5:13 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 09/13] scsi: fnic: Send NVMe LS requests through FDLS Karan Tilak Kumar
2026-06-24 5:11 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 10/13] scsi: fnic: Abort timed-out NVMe LS requests Karan Tilak Kumar
2026-06-24 5:13 ` sashiko-bot [this message]
2026-06-24 4:43 ` [PATCH v5 11/13] scsi: fnic: Track NVMe transport statistics Karan Tilak Kumar
2026-06-24 5:15 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs Karan Tilak Kumar
2026-06-24 5:17 ` sashiko-bot
2026-06-24 4:43 ` [PATCH v5 13/13] scsi: fnic: Bump up version number Karan Tilak Kumar
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=20260624051331.AEF7C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=kartilak@cisco.com \
--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 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.