From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 55/60] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition()
Date: Fri, 12 Jun 2026 11:38:41 +0000 [thread overview]
Message-ID: <20260612113841.D9C151F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260612095333.1666592-56-njavali@marvell.com>
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
New issues:
- [High] The decrement of `vp->vref_count` lacks a release memory barrier and breaks the driver's locking idiom, potentially leading to a use-after-free write on weakly ordered architectures.
Pre-existing issues:
- [High] The exact same use-after-free vulnerability fixed by this patch in `qla24xx_report_id_acquisition` is present in the NVMe FC path via `qla2xxx_get_vha_from_vp_idx`.
- [High] Target mode processing uses `qla_find_host_by_vp_idx` which returns an unreferenced `vha` pointer, opening a race condition for UAF during vport teardown.
- [High] btree operations on `ha->host_map` via `qla_update_host_map()` are performed without holding `vport_slock`.
- [High] Missing `sess_lock` during `vp_fcports` list traversal in Format 2 branch.
- [High] Invalid use of list_for_each_entry_safe across dropped spinlocks in DPC and alert handlers.
- [High] `qla24xx_report_id_acquisition` ignores `VPORT_DELETE` and can resurrect a deleted vport.
--
commit 95ed94124983f94c25ebc87bace3b12cf63aa94f
Author: Nilesh Javali <njavali@marvell.com>
scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition()
This commit fixes a use-after-free by taking a vport reference
(vref_count) while holding vport_slock when finding a virtual port,
and dropping it after use. This ensures the vport isn't freed by a
concurrent qla24xx_deallocate_vp_id().
Cc: stable@vger.kernel.org
> diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
> index 8a001b489fc0e..bfb931eb14f61 100644
> --- a/drivers/scsi/qla2xxx/qla_mbx.c
> +++ b/drivers/scsi/qla2xxx/qla_mbx.c
> @@ -4275,6 +4275,7 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, void *pkt)
> list_for_each_entry(vp, &ha->vp_list, list) {
> if (vp_idx == vp->vp_idx) {
> found = 1;
> + atomic_inc(&vp->vref_count);
[Severity: High]
This is a pre-existing issue, but does this loop need to check if the vport
is actively being deleted?
If qla24xx_vport_delete() is concurrently removing the vport and has already
taken it out of the host_map, would we resurrect it here?
We take a reference and later re-register it without checking for
VPORT_DELETE on vp->dpc_flags, which might lead to a use-after-free when the
system later queries the map.
> break;
> }
> }
> @@ -4292,6 +4293,8 @@ qla24xx_report_id_acquisition(scsi_qla_host_t *vha, void *pkt)
> set_bit(VP_IDX_ACQUIRED, &vp->vp_flags);
> set_bit(REGISTER_FC4_NEEDED, &vp->dpc_flags);
> set_bit(REGISTER_FDMI_NEEDED, &vp->dpc_flags);
> +
> + atomic_dec(&vp->vref_count);
[Severity: High]
Could the weakly ordered nature of atomic_dec() allow the preceding set_bit()
operations to be reordered after the decrement?
In the kernel, set_bit() and atomic_dec() do not imply memory barriers.
On weakly ordered architectures, the atomic_dec() could become visible
before the stores to vp->vp_flags and vp->dpc_flags.
If qla24xx_deallocate_vp_id() polls vref_count concurrently, could it
observe vref_count == 0 early, proceeding to unlink the vport before the
flags are fully updated?
Would it be safer to enclose the atomic_dec() within vport_slock, matching
how the reference is acquired?
> }
> set_bit(VP_DPC_NEEDED, &vha->dpc_flags);
[Severity: High]
This is a pre-existing issue, but are we modifying the host_map without
holding the required lock in this same function?
Just before the snippet above, qla_update_host_map() evaluates to
qla_update_vp_map() which inserts the vp into the ha->host_map btree. The
documentation for qla_update_vp_map() states it requires vport_slock:
drivers/scsi/qla2xxx/qla_mid.c:qla_update_vp_map() {
/* vport_slock to be held by the caller */
...
btree_insert32(&ha->host_map, ...);
}
Since we dropped ha->vport_slock before this call, could concurrent
modifications corrupt the btree?
[Severity: High]
This isn't a bug introduced by this patch, but should we be holding
sess_lock while iterating vp_fcports in the Format 2 path of
qla24xx_report_id_acquisition()?
In the Format 1 path, the list is traversed with sess_lock held.
However, in the Format 2 path, we traverse the list and call
qla2x00_find_fcport_by_wwpn() without holding vha->hw->tgt.sess_lock:
drivers/scsi/qla2xxx/qla_mbx.c:qla24xx_report_id_acquisition() {
...
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);
...
}
Could this lack of locking lead to list corruption or use-after-free if
vp_fcports is modified concurrently?
[Severity: High]
This is a pre-existing issue, but does the NVMe FC path suffer from a similar
use-after-free vulnerability as the one fixed in this patch?
When calling qla2xxx_get_vha_from_vp_idx() in qla_nvme.c, the lock is dropped
and the vha pointer is returned without incrementing vref_count:
drivers/scsi/qla2xxx/qla_nvme.c:qla2xxx_get_vha_from_vp_idx() {
if (vha->vp_idx == vp_index) {
spin_unlock_irqrestore(&ha->vport_slock, flags);
return vha;
}
}
The caller, qla2xxx_process_purls_iocb(), then heavily uses this unreferenced
pointer. Could a concurrent qla24xx_deallocate_vp_id() tear down the vport
and free it, causing a use-after-free in the NVMe response path?
[Severity: High]
This is a pre-existing issue, but does qla_find_host_by_vp_idx() also leak
unreferenced pointers in target mode?
drivers/scsi/qla2xxx/qla_mid.c:qla_find_host_by_vp_idx() {
if (likely(test_bit(vp_idx, ha->vp_idx_map)))
return ha->vp_map[vp_idx].vha;
}
Various target mode functions route commands to the vport returned by this
lookup. Since no reference is taken, couldn't qla24xx_deallocate_vp_id()
free the vha concurrently?
[Severity: High]
This is a pre-existing issue, but is it safe to use list_for_each_entry_safe()
when dropping the spinlock in DPC and alert handlers?
In qla2x00_do_dpc_all_vps(), the lock is dropped inside the safe iteration
loop:
drivers/scsi/qla2xxx/qla_mid.c:qla2x00_do_dpc_all_vps() {
spin_lock_irqsave(&ha->vport_slock, flags);
list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
if (vp->vp_idx) {
atomic_inc(&vp->vref_count);
spin_unlock_irqrestore(&ha->vport_slock, flags);
...
spin_lock_irqsave(&ha->vport_slock, flags);
}
Since list_for_each_entry_safe() caches the next element (tvp), if a
concurrent deletion removes tvp from the list and frees it while the lock
is dropped, won't resuming the loop result in a use-after-free?
A similar pattern exists in qla2x00_alert_all_vps().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612095333.1666592-1-njavali@marvell.com?part=55
next prev parent reply other threads:[~2026-06-12 11:38 UTC|newest]
Thread overview: 154+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 9:52 [PATCH v2 00/60] scsi: qla2xxx: Add QLA29xx series adapter support Nilesh Javali
2026-06-12 9:52 ` [PATCH v2 01/60] scsi: qla2xxx: Add 29xx series PCI device ID support Nilesh Javali
2026-06-12 10:30 ` sashiko-bot
2026-06-12 10:40 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 02/60] scsi: qla2xxx: Add flash read/write interface for 29xx Nilesh Javali
2026-06-12 10:16 ` sashiko-bot
2026-06-12 10:43 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 03/60] scsi: qla2xxx: Add NVRAM config support for 29xx adapters Nilesh Javali
2026-06-12 10:46 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 04/60] scsi: qla2xxx: Add get_flash_version " Nilesh Javali
2026-06-12 10:18 ` sashiko-bot
2026-06-12 10:48 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 05/60] scsi: qla2xxx: Add 29xx support in queue initialisation path Nilesh Javali
2026-06-12 10:17 ` sashiko-bot
2026-06-12 10:49 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 06/60] scsi: qla2xxx: Add FC operational firmware load for 29xx Nilesh Javali
2026-06-12 10:14 ` sashiko-bot
2026-06-12 10:52 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 07/60] scsi: qla2xxx: Add flash block read/write BSG support " Nilesh Javali
2026-06-12 10:11 ` sashiko-bot
2026-06-12 10:55 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 08/60] scsi: qla2xxx: Add BSG MPI firmware load/dump " Nilesh Javali
2026-06-12 10:14 ` sashiko-bot
2026-06-12 10:57 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 09/60] scsi: qla2xxx: Add 128-byte IOCB definitions " Nilesh Javali
2026-06-12 11:01 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 10/60] scsi: qla2xxx: Add extended status continuation and marker IOCBs Nilesh Javali
2026-06-12 11:02 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 11/60] scsi: qla2xxx: Remove duplicate flash memo block definitions Nilesh Javali
2026-06-12 11:03 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 12/60] scsi: qla2xxx: Update IO path to use 128-byte IOCBs for 29xx Nilesh Javali
2026-06-12 10:29 ` sashiko-bot
2026-06-12 11:12 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 13/60] scsi: qla2xxx: Replace IS_QLA29XX() size checks with entry-size helpers Nilesh Javali
2026-06-12 11:14 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 14/60] scsi: qla2xxx: Skip image-set-valid attribute for 29xx Nilesh Javali
2026-06-12 11:14 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 15/60] scsi: qla2xxx: Skip unsupported sysfs attributes " Nilesh Javali
2026-06-12 10:28 ` sashiko-bot
2026-06-12 11:15 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 16/60] scsi: qla2xxx: Enable get_fw_version mailbox " Nilesh Javali
2026-06-12 10:31 ` sashiko-bot
2026-06-12 11:16 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 17/60] scsi: qla2xxx: Extend execute_fw mailbox to include 29xx Nilesh Javali
2026-06-12 10:25 ` sashiko-bot
2026-06-12 11:17 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 18/60] scsi: qla2xxx: Enable get_adapter_id mailbox for 29xx Nilesh Javali
2026-06-12 11:18 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 19/60] scsi: qla2xxx: Enable init_firmware " Nilesh Javali
2026-06-12 11:18 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 20/60] scsi: qla2xxx: Enable get_firmware_state " Nilesh Javali
2026-06-12 11:19 ` Hannes Reinecke
2026-06-12 11:22 ` sashiko-bot
2026-06-12 9:52 ` [PATCH v2 21/60] scsi: qla2xxx: Enable serdes, resource count and FCE trace " Nilesh Javali
2026-06-12 10:38 ` sashiko-bot
2026-06-12 11:19 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 22/60] scsi: qla2xxx: Enable set_els_cmds and echo_test " Nilesh Javali
2026-06-12 11:20 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 23/60] scsi: qla2xxx: Add support for QLA29XX in data rate functions Nilesh Javali
2026-06-12 11:20 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 24/60] scsi: qla2xxx: Enable qla2x00_shutdown for 29xx Nilesh Javali
2026-06-12 11:21 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 25/60] scsi: qla2xxx: Use ring-slot helpers in __qla2x00_alloc_iocbs Nilesh Javali
2026-06-12 10:41 ` sashiko-bot
2026-06-12 11:21 ` Hannes Reinecke
2026-06-12 9:52 ` [PATCH v2 26/60] scsi: qla2xxx: Add support for QLA29XX in memory allocation Nilesh Javali
2026-06-12 10:40 ` sashiko-bot
2026-06-12 11:22 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 27/60] scsi: qla2xxx: Refactor marker IOCB handling for 29xx series Nilesh Javali
2026-06-12 11:36 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 28/60] scsi: qla2xxx: Handle sts_cont_entry_ext_t for 29xx adapters Nilesh Javali
2026-06-12 10:54 ` sashiko-bot
2026-06-12 11:47 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 29/60] scsi: qla2xxx: Update handling of status entries for 29xx series Nilesh Javali
2026-06-12 10:44 ` sashiko-bot
2026-06-12 12:12 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 30/60] scsi: qla2xxx: Enhance ct_entry_24xx_ext iocb handling " Nilesh Javali
2026-06-12 12:14 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 31/60] scsi: qla2xxx: Enhance purex_entry " Nilesh Javali
2026-06-12 10:54 ` sashiko-bot
2026-06-12 12:16 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 32/60] scsi: qla2xxx: Update handling of ELS IOCBs " Nilesh Javali
2026-06-12 12:33 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 33/60] scsi: qla2xxx: Add size check for ELS status entry layout on 29xx Nilesh Javali
2026-06-12 12:34 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 34/60] scsi: qla2xxx: Add 29xx extended logio IOCB support Nilesh Javali
2026-06-12 12:36 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 35/60] scsi: qla2xxx: Enhance task management IOCB handling for 29xx series Nilesh Javali
2026-06-12 11:13 ` sashiko-bot
2026-06-12 12:37 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 36/60] scsi: qla2xxx: Add abort command " Nilesh Javali
2026-06-12 11:15 ` sashiko-bot
2026-06-12 12:38 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 37/60] scsi: qla2xxx: Enhance ABTS processing " Nilesh Javali
2026-06-12 12:41 ` Hannes Reinecke
2026-06-12 15:12 ` sashiko-bot
2026-06-12 9:53 ` [PATCH v2 38/60] scsi: qla2xxx: Update VP control IOCB handling " Nilesh Javali
2026-06-12 12:45 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 39/60] scsi: qla2xxx: Add build-time size check for VP config IOCB layout Nilesh Javali
2026-06-12 12:45 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 40/60] scsi: qla2xxx: Add size check for extended VP report ID entry Nilesh Javali
2026-06-12 11:05 ` sashiko-bot
2026-06-12 12:46 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 41/60] scsi: qla2xxx: Unify NVMe IOCB build path for 29xx and legacy adapters Nilesh Javali
2026-06-12 11:02 ` sashiko-bot
2026-06-12 12:49 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 42/60] scsi: qla2xxx: Add LS4 pass-through IOCB handling for 29xx series Nilesh Javali
2026-06-12 12:50 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 43/60] scsi: qla2xxx: Convert NVMe ring advance to use qla_req_ring_advance() Nilesh Javali
2026-06-12 12:52 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 44/60] scsi: qla2xxx: Adjust feature gating in BSG paths for 29xx support Nilesh Javali
2026-06-12 11:16 ` sashiko-bot
2026-06-12 12:53 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 45/60] scsi: qla2xxx: Fix queue teardown NULL dma_free and bitmap locking Nilesh Javali
2026-06-12 12:56 ` Hannes Reinecke
2026-06-12 13:23 ` sashiko-bot
2026-06-12 9:53 ` [PATCH v2 46/60] scsi: qla2xxx: Replace __le16 bitfields with scalar and accessors Nilesh Javali
2026-06-12 12:57 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 47/60] scsi: qla2xxx: Fix endianness annotations in vp_rpt_id_entry structures Nilesh Javali
2026-06-12 12:59 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 48/60] scsi: qla2xxx: Use 64-bit FPM word counters for 29xx host stats Nilesh Javali
2026-06-12 13:00 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 49/60] scsi: qla2xxx: Add 64G/128G port speed setting support Nilesh Javali
2026-06-12 13:02 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 50/60] scsi: qla2xxx: Fix 64G link speed reporting in get_data_rate Nilesh Javali
2026-06-12 13:03 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 51/60] scsi: qla2xxx: edif: Fix NULL pointer deref in RX SA delete check Nilesh Javali
2026-06-12 11:43 ` sashiko-bot
2026-06-12 13:04 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 52/60] scsi: qla2xxx: Fix Name Server logout detection on FWI2 adapters Nilesh Javali
2026-06-12 13:08 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 53/60] scsi: qla2xxx: Bound VP index against VP_CTRL IOCB bitmap size Nilesh Javali
2026-06-12 11:35 ` sashiko-bot
2026-06-12 13:09 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 54/60] scsi: qla2xxx: Check entry_status in qla24xx_modify_vp_config() Nilesh Javali
2026-06-12 13:10 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 55/60] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition() Nilesh Javali
2026-06-12 11:38 ` sashiko-bot [this message]
2026-06-12 13:10 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 56/60] scsi: qla2xxx: Initialize NVMe abort_work once at submission Nilesh Javali
2026-06-12 11:34 ` sashiko-bot
2026-06-12 13:11 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 57/60] scsi: qla2xxx: Hold qpair lock when sending NVMe LS reject Nilesh Javali
2026-06-12 11:39 ` sashiko-bot
2026-06-12 13:11 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 58/60] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Nilesh Javali
2026-06-12 11:40 ` sashiko-bot
2026-06-12 13:12 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 59/60] scsi: qla2xxx: Fix BSG job leak on validate flash image error path Nilesh Javali
2026-06-12 11:38 ` sashiko-bot
2026-06-12 13:12 ` Hannes Reinecke
2026-06-12 9:53 ` [PATCH v2 60/60] scsi: qla2xxx: Bound image count in qla2x00_update_fru_versions() Nilesh Javali
2026-06-12 11:45 ` sashiko-bot
2026-06-12 13:13 ` Hannes Reinecke
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=20260612113841.D9C151F000E9@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.