From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 05/56] scsi: qla2xxx: Add FC operational firmware load for 29xx
Date: Thu, 23 Jul 2026 06:44:10 +0000 [thread overview]
Message-ID: <20260723064410.9BADD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723050413.3897522-6-njavali@marvell.com>
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
New issues:
- [High] The `.start_scsi` function pointer is missing from the `qla29xx_isp_ops` structure.
- [High] The `.read_optrom` and `.write_optrom` callbacks in `qla29xx_isp_ops` incorrectly use legacy handlers that trigger invalid flash accesses.
- [High] `qla29xx_load_fw_template()` misinterprets the firmware dump template size as bytes instead of dwords, leading to severe memory under-allocation.
- [High] `qla29xx_load_fw_template()` fails to skip the flash region header when extracting the firmware dump template, breaking validation.
- [High] Firmware dump template validation failures in 29xx load paths incorrectly abort the entire adapter initialization.
Pre-existing issues:
- [High] Use-After-Free in `ha->mpi_fw_dump` pointer when firmware dump buffer is reallocated.
--
--- Patch [5]: [PATCH v6 05/56] scsi: qla2xxx: Add FC operational firmware load for 29xx ---
commit ed0a0bf5b60c5fe925e18499926faba91b6ac03a
Author: Manish Rangankar <mrangankar@marvell.com>
scsi: qla2xxx: Add FC operational firmware load for 29xx
This commit adds support to load the 29xx FC operational firmware from the
filesystem and to set up the corresponding firmware dump template. It
follows the same request_firmware and segment load pattern used by earlier
adapters.
> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -3937,7 +3937,8 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *vha)
> "Allocated (%d KB) for firmware dump.\n",
> dump_size / 1024);
>
> - if (IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
> + if (IS_QLA27XX(ha) || IS_QLA28XX(ha) ||
> + IS_QLA29XX(ha)) {
> ha->mpi_fw_dump = (char *)fw_dump +
> ha->fwdt[1].dump_size;
> mutex_unlock(&ha->optrom_mutex);
[Severity: High]
This is a pre-existing issue, but does adding 29xx to this path expose a
use-after-free when the firmware dump buffer is reallocated?
Earlier in qla2x00_alloc_fw_dump(), when ha->fw_dumped is true, the old
buffer is freed via vfree(ha->fw_dump) and reallocated. However, the
ha->mpi_fw_dump pointer is not updated to point into the new buffer. It
seems it will remain pointing to the freed memory, and a subsequent MPI
firmware dump would corrupt memory.
[ ... ]
> +static int
> +qla29xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
> +{
[ ... ]
> +failed:
> + vfree(fwdt->template);
> + fwdt->template = NULL;
> + fwdt->length = 0;
> +img_corrupt:
> + vfree(header);
> + return QLA_FUNCTION_FAILED;
> +}
[Severity: High]
Should template validation failures in the 29xx load paths abort the entire
adapter initialization?
In previous hardware generations, firmware dump template failures are
treated as non-fatal and return QLA_SUCCESS, allowing the driver to operate
without firmware dump capabilities. Returning QLA_FUNCTION_FAILED here
propagates up and makes the adapter completely unusable if the optional
template validation fails.
[ ... ]
> +static int
> +qla29xx_load_fw_template(scsi_qla_host_t *vha)
> +{
[ ... ]
> + template_size = le32_to_cpu(((__le32 *)fw_dump_tmplt)[2]);
> +
> + ql_dbg(ql_dbg_init, vha, 0x0161,
> + "-> fwdt%u template array at %p (0x%x bytes)\n",
> + j, fw_dump_tmplt, template_size);
> +
> + if (!template_size || !~template_size ||
> + template_size > ha->fw_dump_tmplt_len) {
> + ql_dbg(ql_dbg_init, vha, 0x0162,
> + "-> fwdt%u failed to read array\n", j);
> + goto failed;
> + }
> +
> + fwdt->template = vmalloc(template_size);
[Severity: High]
Does this misinterpret the firmware dump template size as bytes instead of
dwords?
The template_size is read from the flash header which typically stores the
size in dwords. Passing this directly to vmalloc() and memcpy() would
allocate and copy only 25 percent of the needed memory, and guarantee that
the subsequent size verification (len > template_size) fails.
> + if (!fwdt->template) {
> + ql_log(ql_log_warn, vha, 0x0164,
> + "-> fwdt%u failed allocate template.\n", j);
> + goto failed;
> + }
> +
> + dcode = fwdt->template;
> + memcpy((char *)dcode, (char *)fw_dump_tmplt, template_size);
> +
> + if (!qla27xx_fwdt_template_valid(dcode)) {
[Severity: High]
Does this copy fail to skip the 7-dword flash region header?
Other firmware load functions skip the header before extracting the
template. Copying directly from offset 0 means the dcode buffer points to
the flash header instead of the template header, which would cause
qla27xx_fwdt_template_valid() to unconditionally fail.
[ ... ]
> +free_fw_dump:
> + kfree(fw_dump_tmplt);
> + return QLA_FUNCTION_FAILED;
> +}
[Severity: High]
As mentioned above, should this optional firmware dump template failure
abort the entire adapter initialization? Returning QLA_FUNCTION_FAILED here
will fail the probe.
[ ... ]
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -2640,6 +2640,45 @@ static struct isp_operations qla27xx_isp_ops = {
> .initialize_adapter = qla2x00_initialize_adapter,
> };
>
> +static struct isp_operations qla29xx_isp_ops = {
> + .pci_config = qla25xx_pci_config,
[Severity: High]
The start_scsi function pointer appears to be missing from the
qla29xx_isp_ops structure.
In qla2xxx_queuecommand(), if ha->mqenable evaluates to 0 (which happens if
MSI-X allocation fails or is disabled by user), the driver falls back to
single-queue mode and explicitly calls ha->isp_ops->start_scsi(). Does this
missing callback cause a fatal NULL pointer dereference on the first
submitted SCSI I/O?
[ ... ]
> + .beacon_on = qla24xx_beacon_on,
> + .beacon_off = qla24xx_beacon_off,
> + .beacon_blink = qla83xx_beacon_blink,
> + .read_optrom = qla25xx_read_optrom_data,
> + .write_optrom = qla24xx_write_optrom_data,
[Severity: High]
Are these legacy flash I/O functions compatible with the 29xx adapter?
These functions compute flash addresses using flash_data_addr(), which adds
ha->flash_data_off to the offset. For 29xx, ha->flash_data_off is
initialized to ~0 (0xFFFFFFFF). This appears to cause invalid flash reads
and writes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723050413.3897522-1-njavali@marvell.com?part=5
next prev parent reply other threads:[~2026-07-23 6:44 UTC|newest]
Thread overview: 65+ 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:03 ` [PATCH v6 02/56] scsi: qla2xxx: Add flash read/write interface for 29xx Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 03/56] scsi: qla2xxx: Add NVRAM config support for 29xx adapters Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 04/56] scsi: qla2xxx: Add 29xx support in queue initialisation path Nilesh Javali
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 [this message]
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 5:03 ` [PATCH v6 16/56] scsi: qla2xxx: Enable get_adapter_id mailbox for 29xx Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 17/56] scsi: qla2xxx: Enable init_firmware " Nilesh Javali
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 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 5:03 ` [PATCH v6 22/56] scsi: qla2xxx: Enable qla2x00_shutdown for 29xx Nilesh Javali
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 5:03 ` [PATCH v6 25/56] scsi: qla2xxx: Handle sts_cont_entry_ext_t for 29xx adapters Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 26/56] scsi: qla2xxx: Update handling of status entries for 29xx series Nilesh Javali
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 5:03 ` [PATCH v6 29/56] scsi: qla2xxx: Update handling of ELS IOCBs " Nilesh Javali
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 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 5:03 ` [PATCH v6 33/56] scsi: qla2xxx: Add abort command " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 34/56] scsi: qla2xxx: Enhance ABTS processing " Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 35/56] scsi: qla2xxx: Update VP control IOCB handling " Nilesh Javali
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 5:03 ` [PATCH v6 38/56] scsi: qla2xxx: Add LS4 pass-through IOCB handling for 29xx series Nilesh Javali
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 5:03 ` [PATCH v6 40/56] scsi: qla2xxx: Fix queue teardown NULL dma_free and bitmap locking Nilesh Javali
2026-07-23 5:03 ` [PATCH v6 41/56] scsi: qla2xxx: Replace __le16 bitfields with scalar and accessors Nilesh Javali
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 5:04 ` [PATCH v6 45/56] scsi: qla2xxx: Fix 64G link speed reporting in get_data_rate Nilesh Javali
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 5:04 ` [PATCH v6 50/56] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition() Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 51/56] scsi: qla2xxx: Initialize NVMe abort_work once at submission Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 52/56] scsi: qla2xxx: Hold qpair lock when sending NVMe LS reject Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 53/56] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Nilesh Javali
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 5:04 ` [PATCH v6 55/56] scsi: qla2xxx: Bound image count in qla2x00_update_fru_versions() Nilesh Javali
2026-07-23 5:04 ` [PATCH v6 56/56] scsi: qla2xxx: Update version to 12.00.00.2607b1 Nilesh Javali
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=20260723064410.9BADD1F000E9@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