From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 37/56] scsi: qla2xxx: Add size check for extended VP report ID entry
Date: Thu, 23 Jul 2026 16:31:55 +0000 [thread overview]
Message-ID: <20260723163157.652631F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723050413.3897522-38-njavali@marvell.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] Extracting `vp_idx` and `vp_status` using C bitfields over a little-endian `__le16` type causes undefined behavior and data corruption on Big-Endian architectures.
Pre-existing issues:
- [High] The vport pointer (`vp`) is accessed after `ha->vport_slock` is released without holding a reference, leading to a potential Use-After-Free.
- [High] The `fcport` list is traversed locklessly for Format 2 RIDA IOCBs, and the found `fcport` is accessed after dropping `tgt.sess_lock` without holding a reference, leading to data races and Use-After-Free.
- [High] Missing `dma_rmb()` read barrier after polling the hardware DMA response queue signature.
--
--- Patch [37]: [PATCH v6 37/56] scsi: qla2xxx: Add size check for extended VP report ID entry ---
commit b119ba076c242111b3050f1eff45472d3fdf947f
Author: Nilesh Javali <njavali@marvell.com>
scsi: qla2xxx: Add size check for extended VP report ID entry
Add reserved_end[64] padding to bring the struct to 128 bytes, matching
the hardware IOCB stride. Change qla24xx_report_id_acquisition() to
accept a void pointer and extract vp_idx and vp_status from the extended
structure on 29xx series adapters.
> diff --git a/drivers/scsi/qla2xxx/qla_fw29.h b/drivers/scsi/qla2xxx/qla_fw29.h
> index 088a220472a50..a4aa5bacb171a 100644
> --- a/drivers/scsi/qla2xxx/qla_fw29.h
> +++ b/drivers/scsi/qla2xxx/qla_fw29.h
[ ... ]
> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
> index 128138b4d16a9..085961e04ec2d 100644
> --- a/drivers/scsi/qla2xxx/qla_isr.c
> +++ b/drivers/scsi/qla2xxx/qla_isr.c
> @@ -4175,8 +4175,7 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
[Severity: High]
This isn't a bug introduced by this patch, but looking at
qla24xx_process_response_queue(), is a dma_rmb() read barrier needed after
polling the hardware DMA response queue signature?
The driver checks if the signature is valid:
while (rsp->ring_index != rsp_in &&
rsp->ring_ptr->signature != RESPONSE_PROCESSED) {
pkt = (void *)rsp->ring_ptr;
cur_ring_index = rsp->ring_index;
qla_rsp_ring_advance(rsp);
if (((response_t *)pkt)->entry_status != 0) {
Without a dma_rmb() barrier after observing the valid signature, can the CPU
speculatively reorder reads and fetch the queue entry payload before the
hardware's DMA write is fully visible?
> qla_sts_cont_data_size(rsp->hw));
> break;
> case VP_RPT_ID_IOCB_TYPE:
> - qla24xx_report_id_acquisition(vha,
> - (struct vp_rpt_id_entry_24xx *)pkt);
> + qla24xx_report_id_acquisition(vha, pkt);
> break;
> case LOGINOUT_PORT_IOCB_TYPE:
> qla24xx_logio_entry(vha, rsp->req, pkt);
[ ... ]
> diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
> index 3ebda35dd584f..cec308811d9eb 100644
> --- a/drivers/scsi/qla2xxx/qla_mbx.c
> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
> @@ -4086,15 +4086,18 @@ qla2x00_set_idma_speed(scsi_qla_host_t *vha, uint16_t loop_id,
> }
>
> void
> -qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
> - struct vp_rpt_id_entry_24xx *rptid_entry)
> +qla24xx_report_id_acquisition(scsi_qla_host_t *vha, void *pkt)
> {
> struct qla_hw_data *ha = vha->hw;
> + struct vp_rpt_id_entry_24xx *rptid_entry = pkt;
> + struct vp_rpt_id_entry_24xx_ext *rptid_entry_ext = pkt;
> scsi_qla_host_t *vp = NULL;
> unsigned long flags;
> int found;
> port_id_t id;
> struct fc_port *fcport;
> + u16 vp_idx;
> + u8 vp_status;
>
> ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x10b6,
> "Entered %s.\n", __func__);
> @@ -4102,6 +4105,14 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
> if (rptid_entry->entry_status != 0)
> return;
>
> + if (IS_QLA29XX(ha)) {
> + vp_idx = rptid_entry_ext->vp_idx;
> + vp_status = rptid_entry_ext->vp_status;
[Severity: High]
Does this extract the wrong bits on big-endian architectures?
struct vp_rpt_id_entry_24xx_ext defines vp_idx and vp_status as bitfields
over an __le16 type:
__le16 vp_idx : 9; /* VP Index 9bits */
__le16 vp_status : 7; /* VP Status 7bits */
Since C bitfield layout is implementation- and endian-dependent, the
compiler on big-endian CPUs typically allocates the first bitfield to the
most significant bits.
Since the hardware writes the DMA data in little-endian format, should this
be defined as a single __le16 field and parsed via le16_to_cpu() combined
with bitwise masks to ensure it is endian-safe?
> + } else {
> + vp_idx = rptid_entry->vp_idx;
> + vp_status = rptid_entry->vp_status;
> + }
> +
> id.b.domain = rptid_entry->port_id[2];
> id.b.area = rptid_entry->port_id[1];
[ ... ]
> @@ -4241,18 +4251,18 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha,
> set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags);
> set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags);
> } else {
> - if (rptid_entry->vp_status != VP_STAT_COMPL &&
> - rptid_entry->vp_status != VP_STAT_ID_CHG) {
> + if (vp_status != VP_STAT_COMPL &&
> + vp_status != VP_STAT_ID_CHG) {
> ql_dbg(ql_dbg_mbx, vha, 0x10ba,
> "Could not acquire ID for VP[%d].\n",
> - rptid_entry->vp_idx);
> + vp_idx);
> return;
> }
>
> found = 0;
> spin_lock_irqsave(&ha->vport_slock, flags);
> list_for_each_entry(vp, &ha->vp_list, list) {
> - if (rptid_entry->vp_idx == vp->vp_idx) {
> + if (vp_idx == vp->vp_idx) {
> found = 1;
> break;
> }
> }
[Severity: High]
This is a pre-existing issue, but can this lead to a use-after-free of the
vp pointer?
In qla24xx_report_id_acquisition(), the code iterates over ha->vp_list while
holding ha->vport_slock to find a matching vp. Once found, the lock is
released without taking a reference count (e.g., atomic_inc(&vp->vref_count)).
Can vp be concurrently removed from the list and freed by qla24xx_vport_delete(),
resulting in a use-after-free when the unreferenced vp is subsequently passed
to qla_update_host_map(vp, id)?
[ ... ]
[Severity: High]
This is also a pre-existing issue, but I see fcport accessed outside of its
protective lock in qla24xx_report_id_acquisition().
In the Format 1 path, sess_lock is held during lookup but dropped immediately:
fcport = qla2x00_find_fcport_by_wwpn(vha,
rptid_entry->u.f1.port_name, 1);
spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags);
if (fcport) {
fcport->plogi_nack_done_deadline = jiffies + HZ;
Could a concurrent session deletion free this memory, causing a use-after-free
when fcport is modified?
Also, in the Format 2 path, the list is traversed locklessly:
list_for_each_entry(fcport, &vha->vp_fcports, list) {
fcport->scan_state = QLA_FCPORT_SCAN;
fcport->n2n_flag = 0;
}
fcport = qla2x00_find_fcport_by_wwpn(vha,
rptid_entry->u.f2.port_name, 1);
Can this cause list corruption or a crash on stale pointers if other contexts
modify this list under sess_lock?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723050413.3897522-1-njavali@marvell.com?part=37
next prev parent reply other threads:[~2026-07-23 16:31 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 5:03 [PATCH v6 00/56] scsi: qla2xxx: Add QLA29xx series adapter support Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 01/56] scsi: qla2xxx: Add 29xx series PCI device ID support Nilesh Javali
2026-07-23 5:29 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 02/56] scsi: qla2xxx: Add flash read/write interface for 29xx Nilesh Javali
2026-07-23 5:51 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 03/56] scsi: qla2xxx: Add NVRAM config support for 29xx adapters Nilesh Javali
2026-07-23 6:03 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 04/56] scsi: qla2xxx: Add 29xx support in queue initialisation path Nilesh Javali
2026-07-23 6:19 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 05/56] scsi: qla2xxx: Add FC operational firmware load for 29xx Nilesh Javali
2026-07-23 6:44 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 06/56] scsi: qla2xxx: Remove redundant VPD flash read in sysfs read path Nilesh Javali
2026-07-23 6:53 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 07/56] scsi: qla2xxx: Add flash block read/write BSG support for 29xx Nilesh Javali
2026-07-23 7:11 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 08/56] scsi: qla2xxx: Add BSG MPI firmware load/dump " Nilesh Javali
2026-07-23 7:24 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 09/56] scsi: qla2xxx: Add 128-byte IOCB definitions " Nilesh Javali
2026-07-23 7:35 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 10/56] scsi: qla2xxx: Add extended status continuation and marker IOCBs Nilesh Javali
2026-07-23 7:43 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 11/56] scsi: qla2xxx: Update IO path to use 128-byte IOCBs for 29xx Nilesh Javali
2026-07-23 8:25 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 12/56] scsi: qla2xxx: Skip image-set-valid attribute " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 13/56] scsi: qla2xxx: Skip unsupported sysfs attributes " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 14/56] scsi: qla2xxx: Enable get_fw_version mailbox " Nilesh Javali
2026-07-23 9:15 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 15/56] scsi: qla2xxx: Extend execute_fw mailbox to include 29xx Nilesh Javali
2026-07-23 9:26 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 16/56] scsi: qla2xxx: Enable get_adapter_id mailbox for 29xx Nilesh Javali
2026-07-23 9:36 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 17/56] scsi: qla2xxx: Enable init_firmware " Nilesh Javali
2026-07-23 9:45 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 18/56] scsi: qla2xxx: Enable get_firmware_state " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 19/56] scsi: qla2xxx: Enable serdes, resource count and FCE trace " Nilesh Javali
2026-07-23 10:10 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 20/56] scsi: qla2xxx: Enable set_els_cmds and echo_test " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 21/56] scsi: qla2xxx: Add support for QLA29XX in data rate functions Nilesh Javali
2026-07-23 10:25 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 22/56] scsi: qla2xxx: Enable qla2x00_shutdown for 29xx Nilesh Javali
2026-07-23 10:34 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 23/56] scsi: qla2xxx: Use ring-slot helpers in __qla2x00_alloc_iocbs Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 24/56] scsi: qla2xxx: Add support for QLA29XX in memory allocation Nilesh Javali
2026-07-23 10:56 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 25/56] scsi: qla2xxx: Handle sts_cont_entry_ext_t for 29xx adapters Nilesh Javali
2026-07-23 11:12 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 26/56] scsi: qla2xxx: Update handling of status entries for 29xx series Nilesh Javali
2026-07-23 13:25 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 27/56] scsi: qla2xxx: Enhance ct_entry_24xx_ext iocb handling " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 28/56] scsi: qla2xxx: Enhance purex_entry " Nilesh Javali
2026-07-23 14:09 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 29/56] scsi: qla2xxx: Update handling of ELS IOCBs " Nilesh Javali
2026-07-23 14:25 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 30/56] scsi: qla2xxx: Add size check for ELS status entry layout on 29xx Nilesh Javali
2026-07-23 14:39 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 31/56] scsi: qla2xxx: Add 29xx extended logio IOCB support Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 32/56] scsi: qla2xxx: Enhance task management IOCB handling for 29xx series Nilesh Javali
2026-07-23 15:08 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 33/56] scsi: qla2xxx: Add abort command " Nilesh Javali
2026-07-23 15:28 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 34/56] scsi: qla2xxx: Enhance ABTS processing " Nilesh Javali
2026-07-23 15:53 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 35/56] scsi: qla2xxx: Update VP control IOCB handling " Nilesh Javali
2026-07-23 16:12 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 36/56] scsi: qla2xxx: Add build-time size check for VP config IOCB layout Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 37/56] scsi: qla2xxx: Add size check for extended VP report ID entry Nilesh Javali
2026-07-23 16:31 ` sashiko-bot [this message]
2026-07-23 5:03 ` [PATCH v6 38/56] scsi: qla2xxx: Add LS4 pass-through IOCB handling for 29xx series Nilesh Javali
2026-07-23 16:47 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 39/56] scsi: qla2xxx: Adjust feature gating in BSG paths for 29xx support Nilesh Javali
2026-07-23 17:05 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 40/56] scsi: qla2xxx: Fix queue teardown NULL dma_free and bitmap locking Nilesh Javali
2026-07-23 17:16 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 41/56] scsi: qla2xxx: Replace __le16 bitfields with scalar and accessors Nilesh Javali
2026-07-23 17:29 ` sashiko-bot
2026-07-23 5:03 ` [PATCH v6 42/56] scsi: qla2xxx: Fix endianness annotations in vp_rpt_id_entry structures Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 43/56] scsi: qla2xxx: Use 64-bit FPM word counters for 29xx host stats Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 44/56] scsi: qla2xxx: Add 64G/128G port speed setting support Nilesh Javali
2026-07-23 18:07 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 45/56] scsi: qla2xxx: Fix 64G link speed reporting in get_data_rate Nilesh Javali
2026-07-23 18:17 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 46/56] scsi: qla2xxx: edif: Fix NULL pointer deref in RX SA delete check Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 47/56] scsi: qla2xxx: Fix Name Server logout detection on FWI2 adapters Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 48/56] scsi: qla2xxx: Bound VP index against VP_CTRL IOCB bitmap size Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 49/56] scsi: qla2xxx: Check entry_status in qla24xx_modify_vp_config() Nilesh Javali
2026-07-23 18:56 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 50/56] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition() Nilesh Javali
2026-07-23 19:12 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 51/56] scsi: qla2xxx: Initialize NVMe abort_work once at submission Nilesh Javali
2026-07-23 19:26 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 52/56] scsi: qla2xxx: Hold qpair lock when sending NVMe LS reject Nilesh Javali
2026-07-23 19:36 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 53/56] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Nilesh Javali
2026-07-23 19:49 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 54/56] scsi: qla2xxx: Fix BSG job leak on validate flash image error path Nilesh Javali
2026-07-23 20:05 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 55/56] scsi: qla2xxx: Bound image count in qla2x00_update_fru_versions() Nilesh Javali
2026-07-23 20:16 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 56/56] scsi: qla2xxx: Update version to 12.00.00.2607b1 Nilesh Javali
2026-07-23 20:27 ` 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=20260723163157.652631F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=njavali@marvell.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.