From: sashiko-bot@kernel.org
To: "Karan Tilak Kumar" <kartilak@cisco.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 12/13] scsi: fnic: Expose NVMe transport state in debugfs
Date: Wed, 24 Jun 2026 05:17:32 +0000 [thread overview]
Message-ID: <20260624051732.C4A361F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260624044334.3079-13-kartilak@cisco.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The NVMe debugfs file is created and exposed to user space before the data structures and locks it depends on are initialized, creating a race condition that can trigger a NULL pointer dereference and uninitialized spinlock access.
--
commit 82342d5cda06cd97fbd3a125f13faf76b39082ad
Author: Karan Tilak Kumar <kartilak@cisco.com>
scsi: fnic: Expose NVMe transport state in debugfs
Create an NVMe debugfs directory with a per-host nvmef_info file,
reporting local-port and target-port identifiers for NVMe initiator
instances.
> diff --git a/drivers/scsi/fnic/fnic_main.c b/drivers/scsi/fnic/fnic_main.c
> index df8c8ebbc32b9..245db1b992b51 100644
> --- a/drivers/scsi/fnic/fnic_main.c
> +++ b/drivers/scsi/fnic/fnic_main.c
[ ... ]
> @@ -933,6 +933,7 @@ static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> err = -EOPNOTSUPP;
> goto err_out_fnic_role;
> case VFCF_FC_NVME_INITIATOR:
> + fnic_nvmef_debugfs_init(fnic);
[Severity: High]
Is it safe to create and expose the debugfs file nvmef_info this early in
the probe sequence?
At this point in fnic_probe(), the fnic structure has been allocated with
kzalloc(), but critical structures like fnic_lock and iport->tport_list
haven't been initialized yet. They appear to be initialized later in the
function or in fnic_fdls_init().
If a process concurrently opens and reads this debugfs file right after
fnic_nvmef_debugfs_init() returns, could it trigger a crash?
> fnic->role = FNIC_ROLE_NVME_INITIATOR;
> dev_info(&fnic->pdev->dev, "fnic: %d is NVME initiator\n",
> fnic->fnic_num);
[ ... ]
> diff --git a/drivers/scsi/fnic/fnic_nvme.c b/drivers/scsi/fnic/fnic_nvme.c
> index e322dd4dcb787..a19dd9cf76cf9 100644
> --- a/drivers/scsi/fnic/fnic_nvme.c
> +++ b/drivers/scsi/fnic/fnic_nvme.c
[ ... ]
> @@ -188,6 +188,36 @@ void nvfnic_release_nvme_ioreq_buf(struct fnic_iport_s *iport,
> fnic->io_sgl_pool[io_req->sgl_type]);
> }
>
> +int nvfnic_get_nvmef_info(struct fnic *fnic, struct fnic_nvmef_info *info)
> +{
> + int len = 0;
> + struct fnic_iport_s *iport = &fnic->iport;
> + int buf_size = info->buf_size;
> + struct fnic_tport_s *tport;
> + struct fnic_tport_s *next;
> + unsigned long flags;
> +
> + if (buf_size <= 0)
> + return 0;
> +
> + len += scnprintf(info->info_buffer + len, buf_size - len,
> + "lport wwpn 0x%llx wwnn 0x%llx fcid 0x%06x\n",
> + iport->wwpn, iport->wwnn, iport->fcid);
> +
> + spin_lock_irqsave(&fnic->fnic_lock, flags);
> + list_for_each_entry_safe(tport, next, &iport->tport_list, links) {
[Severity: High]
If nvfnic_get_nvmef_info() is executed concurrently before the fnic
struct is fully initialized, will this attempt to acquire an
uninitialized fnic_lock?
Furthermore, if iport->tport_list is still zeroed from the kzalloc(),
the list_for_each_entry_safe() macro expects a properly initialized
list head. Could passing a zeroed list head cause a NULL pointer
dereference when computing the next pointer for the first entry?
> + if (len >= buf_size - 1)
> + break;
> +
> + len += scnprintf(info->info_buffer + len, buf_size - len,
> + "tport wwpn 0x%llx wwnn 0x%llx fcid 0x%06x\n",
> + tport->wwpn, tport->wwnn, tport->fcid);
> + }
> + spin_unlock_irqrestore(&fnic->fnic_lock, flags);
> +
> + return len;
> +}
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260624044334.3079-1-kartilak@cisco.com?part=12
next prev parent reply other threads:[~2026-06-24 5:17 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
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 [this message]
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=20260624051732.C4A361F000E9@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.