From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 04/88] scsi: qla2xxx: Add 29xx support in queue initialisation path
Date: Tue, 07 Jul 2026 06:31:15 +0000 [thread overview]
Message-ID: <20260707063116.53D5B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260707055435.2680300-5-njavali@marvell.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [Critical] The base queue (queue 0) allocation in `qla2x00_mem_alloc()` is not updated to allocate 128-byte entries for QLA29XX, leading to hardware DMA overruns.
- [Critical] The patch enlarges queue DMA buffers to 128-byte strides for 29xx but retains 64-byte pointer arithmetic, corrupting shadow pointers and fast-path iteration.
Pre-existing issues:
- [High] Inconsistent locking protecting the multiqueue mappings (`req_q_map`/`req_qid_map` and `rsp_q_map`/`rsp_qid_map`) leads to data races.
- [High] Pending response queue work (`qpair->q_work`) is not canceled before freeing the queue and its lock, leading to a Use-After-Free.
--
--- Patch [4]: [PATCH v3 04/88] scsi: qla2xxx: Add 29xx support in queue initialisation path ---
commit 4452b9447592dcc921780bd1cb74d843e0bd2ad1
Author: Manish Rangankar <mrangankar@marvell.com>
Subject: scsi: qla2xxx: Add 29xx support in queue initialisation path
This patch extends queue initialization to support the larger 128-byte
entries used by the 29xx adapters. It adds extended request and response
structures and updates the queue allocation sizes accordingly.
> The enlarged entry stride doubles the DMA ring memory allocated for
> both request and response queues on 29xx, and all ring pointer
> arithmetic must account for the wider entries (handled by later
> patches in this series).
[Severity: Critical]
Since the current patch enlarges the queue DMA buffers but leaves pointer
arithmetic for later patches, will shadow pointer calculations use the legacy
64-byte stride in the meantime?
For example, in qla25xx_create_req_que() and qla25xx_create_rsp_que():
req->out_ptr = (uint16_t *)(req->ring + req->length);
rsp->in_ptr = (uint16_t *)(rsp->ring + rsp->length);
Because req->ring is a 64-byte typed pointer, this will point to the middle
of the 128-byte stride array, which may miscalculate the hardware shadow
index. Additionally, fast-path iterations like rsp->ring_ptr++ in
qla24xx_process_response_queue() will implicitly advance by 64 bytes instead
of 128 bytes, which could cause the driver to interpret the zeroed padding
as the next response.
[Severity: Critical]
Also, it looks like the base queue allocation in qla2x00_mem_alloc() is not
updated to use the new 128-byte size:
(*req)->ring = dma_alloc_coherent(&ha->pdev->dev,
((*req)->length + 1) * sizeof(request_t),
&(*req)->dma, GFP_KERNEL);
Could this cause hardware DMA overruns during device probe if the base queue
is allocated at half the required size for a 29xx adapter? Is it safe to
separate these changes from the pointer arithmetic and base queue allocation
updates in the series?
> diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
> index c563133f751e8..e75b7ae22bc52 100644
> --- a/drivers/scsi/qla2xxx/qla_mid.c
> +++ b/drivers/scsi/qla2xxx/qla_mid.c
> @@ -574,9 +574,13 @@ qla25xx_free_req_que(struct scsi_qla_host *vha, struct req_que *req)
> {
> struct qla_hw_data *ha = vha->hw;
> uint16_t que_id = req->id;
> + uint16_t reqsz;
> +
> + reqsz = IS_QLA29XX(ha) ? sizeof(struct request_ext) :
> + sizeof(request_t);
>
> dma_free_coherent(&ha->pdev->dev, (req->length + 1) *
> - sizeof(request_t), req->ring, req->dma);
> + reqsz, req->ring, req->dma);
> req->ring = NULL;
> req->dma = 0;
> if (que_id) {
[Severity: High]
This is a pre-existing issue, but is there a data race when cleaning up
these queues?
In qla25xx_create_req_que(), the queue map allocations are protected by
ha->mq_lock. However, in qla25xx_free_req_que() and qla25xx_free_rsp_que(),
it looks like ha->req_q_map is modified without locks, and ha->req_qid_map
is cleared using ha->vport_lock:
ha->req_q_map[que_id] = NULL;
mutex_lock(&ha->vport_lock);
clear_bit(que_id, ha->req_qid_map);
mutex_unlock(&ha->vport_lock);
Could this mismatch allow concurrent queue creation and teardown to race,
potentially leading to array corruption or dual-allocation of the same
queue ID?
[ ... ]
> @@ -594,6 +598,10 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
> {
> struct qla_hw_data *ha = vha->hw;
> uint16_t que_id = rsp->id;
> + uint16_t rspsz;
> +
> + rspsz = IS_QLA29XX(ha) ? sizeof(struct response_ext) :
> + sizeof(response_t);
>
> if (rsp->msix && rsp->msix->have_irq) {
> free_irq(rsp->msix->vector, rsp->msix->handle);
> @@ -601,8 +609,9 @@ qla25xx_free_rsp_que(struct scsi_qla_host *vha, struct rsp_que *rsp)
> rsp->msix->in_use = 0;
> rsp->msix->handle = NULL;
> }
> +
[Severity: High]
This isn't a bug introduced by this patch, but does this teardown path
need to cancel pending response queue work before freeing the DMA memory?
It looks like cancel_work_sync(&qpair->q_work) is not called before
dma_free_coherent() or before kfree(qpair) later on. If an interrupt fires
and queues the work just before free_irq(), could qla_do_work() execute
concurrently and try to access the freed qpair->rsp memory, resulting in a
use-after-free?
> dma_free_coherent(&ha->pdev->dev, (rsp->length + 1) *
> - sizeof(response_t), rsp->ring, rsp->dma);
> + rspsz, rsp->ring, rsp->dma);
> rsp->ring = NULL;
> rsp->dma = 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707055435.2680300-1-njavali@marvell.com?part=4
next prev parent reply other threads:[~2026-07-07 6:31 UTC|newest]
Thread overview: 159+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 5:53 [PATCH v3 00/88] scsi: qla2xxx: Add QLA29xx series adapter support Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 01/88] scsi: qla2xxx: Add 29xx series PCI device ID support Nilesh Javali
2026-07-07 6:21 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 02/88] scsi: qla2xxx: Add flash read/write interface for 29xx Nilesh Javali
2026-07-07 8:24 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 03/88] scsi: qla2xxx: Add NVRAM config support for 29xx adapters Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 04/88] scsi: qla2xxx: Add 29xx support in queue initialisation path Nilesh Javali
2026-07-07 6:31 ` sashiko-bot [this message]
2026-07-07 5:53 ` [PATCH v3 05/88] scsi: qla2xxx: Add FC operational firmware load for 29xx Nilesh Javali
2026-07-07 6:17 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 06/88] scsi: qla2xxx: Remove redundant VPD flash read in sysfs read path Nilesh Javali
2026-07-07 6:13 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 07/88] scsi: qla2xxx: Add flash block read/write BSG support for 29xx Nilesh Javali
2026-07-07 6:21 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 08/88] scsi: qla2xxx: Add BSG MPI firmware load/dump " Nilesh Javali
2026-07-07 6:13 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 09/88] scsi: qla2xxx: Add 128-byte IOCB definitions " Nilesh Javali
2026-07-07 6:14 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 10/88] scsi: qla2xxx: Add extended status continuation and marker IOCBs Nilesh Javali
2026-07-07 6:10 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 11/88] scsi: qla2xxx: Update IO path to use 128-byte IOCBs for 29xx Nilesh Javali
2026-07-07 10:27 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 12/88] scsi: qla2xxx: Skip image-set-valid attribute " Nilesh Javali
2026-07-07 6:12 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 13/88] scsi: qla2xxx: Skip unsupported sysfs attributes " Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 14/88] scsi: qla2xxx: Enable get_fw_version mailbox " Nilesh Javali
2026-07-07 6:12 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 15/88] scsi: qla2xxx: Extend execute_fw mailbox to include 29xx Nilesh Javali
2026-07-07 6:23 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 16/88] scsi: qla2xxx: Enable get_adapter_id mailbox for 29xx Nilesh Javali
2026-07-07 6:15 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 17/88] scsi: qla2xxx: Enable init_firmware " Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 18/88] scsi: qla2xxx: Enable get_firmware_state " Nilesh Javali
2026-07-07 6:15 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 19/88] scsi: qla2xxx: Enable serdes, resource count and FCE trace " Nilesh Javali
2026-07-07 6:36 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 20/88] scsi: qla2xxx: Enable set_els_cmds and echo_test " Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 21/88] scsi: qla2xxx: Add support for QLA29XX in data rate functions Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 22/88] scsi: qla2xxx: Enable qla2x00_shutdown for 29xx Nilesh Javali
2026-07-07 6:27 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 23/88] scsi: qla2xxx: Use ring-slot helpers in __qla2x00_alloc_iocbs Nilesh Javali
2026-07-07 6:26 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 24/88] scsi: qla2xxx: Add support for QLA29XX in memory allocation Nilesh Javali
2026-07-07 6:22 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 25/88] scsi: qla2xxx: Handle sts_cont_entry_ext_t for 29xx adapters Nilesh Javali
2026-07-07 6:31 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 26/88] scsi: qla2xxx: Update handling of status entries for 29xx series Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 27/88] scsi: qla2xxx: Enhance ct_entry_24xx_ext iocb handling " Nilesh Javali
2026-07-07 6:40 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 28/88] scsi: qla2xxx: Enhance purex_entry " Nilesh Javali
2026-07-07 6:35 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 29/88] scsi: qla2xxx: Update handling of ELS IOCBs " Nilesh Javali
2026-07-07 6:35 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 30/88] scsi: qla2xxx: Add size check for ELS status entry layout on 29xx Nilesh Javali
2026-07-07 6:31 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 31/88] scsi: qla2xxx: Add 29xx extended logio IOCB support Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 32/88] scsi: qla2xxx: Enhance task management IOCB handling for 29xx series Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 33/88] scsi: qla2xxx: Add abort command " Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 34/88] scsi: qla2xxx: Enhance ABTS processing " Nilesh Javali
2026-07-07 6:46 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 35/88] scsi: qla2xxx: Update VP control IOCB handling " Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 36/88] scsi: qla2xxx: Add build-time size check for VP config IOCB layout Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 37/88] scsi: qla2xxx: Add size check for extended VP report ID entry Nilesh Javali
2026-07-07 6:46 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 38/88] scsi: qla2xxx: Add LS4 pass-through IOCB handling for 29xx series Nilesh Javali
2026-07-07 6:45 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 39/88] scsi: qla2xxx: Adjust feature gating in BSG paths for 29xx support Nilesh Javali
2026-07-07 6:48 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 40/88] scsi: qla2xxx: Fix queue teardown NULL dma_free and bitmap locking Nilesh Javali
2026-07-07 6:50 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 41/88] scsi: qla2xxx: Replace __le16 bitfields with scalar and accessors Nilesh Javali
2026-07-07 6:49 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 42/88] scsi: qla2xxx: Fix endianness annotations in vp_rpt_id_entry structures Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 43/88] scsi: qla2xxx: Use 64-bit FPM word counters for 29xx host stats Nilesh Javali
2026-07-07 6:49 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 44/88] scsi: qla2xxx: Add 64G/128G port speed setting support Nilesh Javali
2026-07-07 6:52 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 45/88] scsi: qla2xxx: Fix 64G link speed reporting in get_data_rate Nilesh Javali
2026-07-07 5:53 ` [PATCH v3 46/88] scsi: qla2xxx: edif: Fix NULL pointer deref in RX SA delete check Nilesh Javali
2026-07-07 7:09 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 47/88] scsi: qla2xxx: Fix Name Server logout detection on FWI2 adapters Nilesh Javali
2026-07-07 6:53 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 48/88] scsi: qla2xxx: Bound VP index against VP_CTRL IOCB bitmap size Nilesh Javali
2026-07-07 6:55 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 49/88] scsi: qla2xxx: Check entry_status in qla24xx_modify_vp_config() Nilesh Javali
2026-07-07 6:54 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 50/88] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition() Nilesh Javali
2026-07-07 7:03 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 51/88] scsi: qla2xxx: Initialize NVMe abort_work once at submission Nilesh Javali
2026-07-07 7:00 ` sashiko-bot
2026-07-07 5:53 ` [PATCH v3 52/88] scsi: qla2xxx: Hold qpair lock when sending NVMe LS reject Nilesh Javali
2026-07-07 7:07 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 53/88] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Nilesh Javali
2026-07-07 7:06 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 54/88] scsi: qla2xxx: Fix BSG job leak on validate flash image error path Nilesh Javali
2026-07-07 7:03 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 55/88] scsi: qla2xxx: Bound image count in qla2x00_update_fru_versions() Nilesh Javali
2026-07-07 7:05 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 56/88] scsi: qla2xxx: Clamp MSI-X derived queue counts to avoid truncation Nilesh Javali
2026-07-07 7:06 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 57/88] scsi: qla2xxx: Improve firmware dump data capture Nilesh Javali
2026-07-07 7:18 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 58/88] scsi: qla2xxx: Serialize flash version read in reset handler Nilesh Javali
2026-07-07 5:54 ` [PATCH v3 59/88] scsi: qla2xxx: Fix use-after-free of qpair work on queue teardown Nilesh Javali
2026-07-07 7:08 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 60/88] scsi: qla2xxx: Clarify MPI optrom address/length units Nilesh Javali
2026-07-07 5:54 ` [PATCH v3 61/88] scsi: qla2xxx: Fix cs84xx use-after-free on host teardown Nilesh Javali
2026-07-07 7:11 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 62/88] scsi: qla2xxx: Don't query firmware state while chip is down Nilesh Javali
2026-07-07 7:03 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 63/88] scsi: qla2xxx: Zero mailbox struct in qla2x00_get_firmware_state() Nilesh Javali
2026-07-07 7:18 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 64/88] scsi: qla2xxx: Fix FCE trace enable parsing in debugfs Nilesh Javali
2026-07-07 7:11 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 65/88] scsi: qla2xxx: Fix FCE trace use-after-free during firmware dump Nilesh Javali
2026-07-07 7:25 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 66/88] scsi: qla2xxx: Use memset_io() to clear QLAFX00 request ring slot Nilesh Javali
2026-07-07 7:26 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 67/88] scsi: qla2xxx: Null out freed pointers in qla2x00_mem_alloc() error path Nilesh Javali
2026-07-07 7:25 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 68/88] scsi: qla2xxx: Fix response queue over-consumption in __qla_consume_iocb() Nilesh Javali
2026-07-07 5:54 ` [PATCH v3 69/88] scsi: qla2xxx: Fix soft lockup polling continuation IOCB signature Nilesh Javali
2026-07-07 7:19 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 70/88] scsi: qla2xxx: Bound rsp_info_len to avoid OOB sense-data read Nilesh Javali
2026-07-07 7:24 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 71/88] scsi: qla2xxx: Avoid req_q_map double-read in qla2x00_error_entry() Nilesh Javali
2026-07-07 7:21 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 72/88] scsi: qla2xxx: Quiesce response IRQ before freeing request queue Nilesh Javali
2026-07-07 7:22 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 73/88] scsi: qla2xxx: Reject non-SCSI SRB on status IOCB fast path Nilesh Javali
2026-07-07 5:54 ` [PATCH v3 74/88] scsi: qla2xxx: Clamp max_npiv_vports to VP_CTRL bitmap capacity Nilesh Javali
2026-07-07 7:34 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 75/88] scsi: qla2xxx: Avoid double completion in async IOCB timeout Nilesh Javali
2026-07-07 7:37 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 76/88] scsi: qla2xxx: Skip vport under deletion in report ID acquisition Nilesh Javali
2026-07-07 7:27 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 77/88] scsi: qla2xxx: Drop vport reference under lock " Nilesh Javali
2026-07-07 7:33 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 78/88] scsi: qla2xxx: Hold vport_slock for host map update " Nilesh Javali
2026-07-07 7:28 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 79/88] scsi: qla2xxx: Fix NVMe abort reference leak on repeated abort Nilesh Javali
2026-07-07 7:27 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 80/88] scsi: qla2xxx: Skip NVMe LS reject IOCB when FW not started Nilesh Javali
2026-07-07 7:38 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 81/88] scsi: qla2xxx: Unlink NVMe unsol ctx before freeing on LS reject error Nilesh Javali
2026-07-07 7:34 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 82/88] scsi: qla2xxx: Serialize NVMe unsol ctx list with a per-fcport lock Nilesh Javali
2026-07-07 7:38 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 83/88] scsi: qla2xxx: Use coherent DMA buffer for D_Port diagnostics Nilesh Javali
2026-07-07 7:34 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 84/88] scsi: qla2xxx: Zero-init bsg stack buffers to avoid info leak Nilesh Javali
2026-07-07 7:37 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 85/88] scsi: qla2xxx: Validate BSG request_len before reading vendor_cmd[] Nilesh Javali
2026-07-07 7:46 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 86/88] scsi: qla2xxx: Zero SFP DMA buffer in FRU/I2C bsg handlers Nilesh Javali
2026-07-07 7:38 ` sashiko-bot
2026-07-07 5:54 ` [PATCH v3 87/88] scsi: qla2xxx: Bound i2c->length in I2C " Nilesh Javali
2026-07-07 5:54 ` [PATCH v3 88/88] scsi: qla2xxx: Update version to 12.00.00.2607b1 Nilesh Javali
2026-07-07 7:35 ` 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=20260707063116.53D5B1F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox