All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 05/56] scsi: qla2xxx: Add FC operational firmware load for 29xx
Date: Fri, 17 Jul 2026 15:53:20 +0000	[thread overview]
Message-ID: <20260717155321.56AB61F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260717152904.3155730-6-njavali@marvell.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] The `qla29xx_isp_ops` structure is missing the `.start_scsi` function pointer, leading to a NULL pointer dereference.
- [High] `qla29xx_load_fw_template` misinterprets the template size, truncating the buffer, and incorrectly copies the flash wrapper header.
- [Medium] Missing bounds check on `ha->fw_dump_tmplt_len` before parsing template size in `qla29xx_load_fw_template`.
- [Medium] Flawed bounds check when reading `risc_attr` from Array 1 in `qla29xx_load_risc_blob()`.
--

--- Patch [5]: [PATCH v5 05/56] scsi: qla2xxx: Add FC operational firmware load for 29xx ---
commit 1d779103e29201d2b067488fba6b287ea9f225e4
Author: Manish Rangankar <mrangankar@marvell.com>
scsi: qla2xxx: Add FC operational firmware load for 29xx

This commit adds support for loading 29xx FC operational firmware from the
filesystem. It also sets up the corresponding firmware dump template following
the 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
> index c6e928f11758c..5b0dc9b0a679c 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
[ ... ]
> @@ -9128,6 +9131,539 @@ qla81xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr)
> +static int
> +qla29xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t *srisc_addr)
> +{
[ ... ]
> +		/* Array 2 */
> +		offset += header->array1_length;
> +		if (offset + header->array2_length > fw_size) {
> +			ql_log(ql_log_fatal, vha, 0x0098,
> +			       "FW image too small for Arr2 (%#zx > %#zx).\n",
> +			       offset + header->array2_length, fw_size);
> +			goto img_corrupt;
> +		}
> +		rval = qla29xx_process_rd_image(vha, header,
> +			(__be32 *)((char *)fwcode + offset),
> +			ARR2, header->array2_destination_addr,
> +			header->array2_length);
> +		if (rval) {
> +			ql_log(ql_log_fatal, vha, 0x0098,
> +			       "-> Failed load Arr2\n");
> +			goto img_corrupt;
> +		}
> +
> +		/* Array 3: FW_DUMP template */
> +		if (offset + 10 * sizeof(__be32) > fw_size) {
> +			ql_log(ql_log_fatal, vha, 0x0098,
> +			       "FW image too small for risc_attr.\n");
> +			goto img_corrupt;
> +		}
> +		array1_addr = (__be32 *)((char *)fwcode +
> +				header->header_length +
> +				header->tim_length);
> +		risc_attr = be32_to_cpu(array1_addr[9]);

[Severity: Medium]
Does this bounds check correctly protect the read from array1_addr? 

At this point, offset has already been advanced to the start of Array 2.
This checks if there are 40 bytes available after Array 2, but doesn't
verify if Array 1 itself is at least 40 bytes long. If Array 1 is
undersized, array1_addr[9] will erroneously read into Array 2 data.

[ ... ]
> +static int
> +qla29xx_load_fw_template(scsi_qla_host_t *vha)
> +{
> +	struct qla_hw_data *ha = vha->hw;
> +	struct fwdt *fwdt = ha->fwdt;
> +	uint templates = 1;
[ ... ]
> +	for (j = 0; j < templates; j++, fwdt++) {
> +		vfree(fwdt->template);
> +		fwdt->template = NULL;
> +		fwdt->length = 0;
> +
> +		template_size = le32_to_cpu(((__le32 *)fw_dump_tmplt)[2]);

[Severity: Medium]
Could ha->fw_dump_tmplt_len be less than 12 bytes here? If the flash layout
defines a length smaller than 12, this array index will read out of bounds
of the kzalloc buffer.

> +
> +		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);
> +		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);

[Severity: High]
Is template_size stored in dwords in the flash region? If so,
vmalloc(template_size) allocates 1/4th of the required memory.

Also, does the memcpy() need to skip the 7-dword flash wrapper header? As
written, it copies the header into fwdt->template, which will cause
qla27xx_fwdt_template_valid() to fail.

Furthermore, the loop hardcodes templates = 1 and doesn't advance
fw_dump_tmplt, which ignores any secondary MPI firmware dump template.

> +
> +		if (!qla27xx_fwdt_template_valid(dcode)) {
> +			ql_log(ql_log_warn, vha, 0x0165,
> +			       "-> fwdt%u failed template validate (rval %x)\n",
> +			       j, rval);
> +			goto failed;
> +		}
[ ... ]
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index c3eb941f71ad9..6560e58ad87c7 100644
> --- 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,
> +	.reset_chip		= qla24xx_reset_chip,
> +	.chip_diag		= qla24xx_chip_diag,
> +	.config_rings		= qla24xx_config_rings,
> +	.reset_adapter		= qla24xx_reset_adapter,
> +	.nvram_config		= qla81xx_nvram_config,
> +	.update_fw_options	= qla24xx_update_fw_options,
> +	.load_risc		= qla29xx_load_risc,
> +	.pci_info_str		= qla24xx_pci_info_str,
> +	.fw_version_str		= qla24xx_fw_version_str,
> +	.intr_handler		= qla24xx_intr_handler,
> +	.enable_intrs		= qla24xx_enable_intrs,
> +	.disable_intrs		= qla24xx_disable_intrs,
> +	.abort_command		= qla24xx_abort_command,
> +	.target_reset		= qla24xx_abort_target,
> +	.lun_reset		= qla24xx_lun_reset,
> +	.fabric_login		= qla24xx_login_fabric,
> +	.fabric_logout		= qla24xx_fabric_logout,
> +	.calc_req_entries	= NULL,
> +	.build_iocbs		= NULL,
> +	.prep_ms_iocb		= qla24xx_prep_ms_iocb,
> +	.prep_ms_fdmi_iocb	= qla24xx_prep_ms_fdmi_iocb,
> +	.read_nvram		= NULL,
> +	.write_nvram		= NULL,
> +	.fw_dump		= qla27xx_fwdump,
> +	.mpi_fw_dump		= qla27xx_mpi_fwdump,
> +	.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,
> +	.get_flash_version	= qla24xx_get_flash_version,
> +	.start_scsi_mq		= qla2xxx_dif_start_scsi_mq,
> +	.abort_isp		= qla2x00_abort_isp,
> +	.iospace_config		= qla83xx_iospace_config,
> +	.initialize_adapter	= qla2x00_initialize_adapter,
> +};

[Severity: Critical]
Is the missing .start_scsi pointer here intentional? 

If ha->mqenable is false or the designated qpair is NULL (e.g., due to a 
queue mapping failure or fallback to single-queue mode), 
qla2xxx_queuecommand() falls back to the legacy single-queue path by calling
ha->isp_ops->start_scsi(sp). 

Since this pointer is omitted, it defaults to NULL and will result in a NULL
pointer dereference.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717152904.3155730-1-njavali@marvell.com?part=5

  reply	other threads:[~2026-07-17 15:53 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 15:28 [PATCH v5 00/56] scsi: qla2xxx: Add QLA29xx series adapter support Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 01/56] scsi: qla2xxx: Add 29xx series PCI device ID support Nilesh Javali
2026-07-17 16:36   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 02/56] scsi: qla2xxx: Add flash read/write interface for 29xx Nilesh Javali
2026-07-17 16:05   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 03/56] scsi: qla2xxx: Add NVRAM config support for 29xx adapters Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 04/56] scsi: qla2xxx: Add 29xx support in queue initialisation path Nilesh Javali
2026-07-17 16:09   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 05/56] scsi: qla2xxx: Add FC operational firmware load for 29xx Nilesh Javali
2026-07-17 15:53   ` sashiko-bot [this message]
2026-07-17 15:28 ` [PATCH v5 06/56] scsi: qla2xxx: Remove redundant VPD flash read in sysfs read path Nilesh Javali
2026-07-17 15:58   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 07/56] scsi: qla2xxx: Add flash block read/write BSG support for 29xx Nilesh Javali
2026-07-17 16:02   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 08/56] scsi: qla2xxx: Add BSG MPI firmware load/dump " Nilesh Javali
2026-07-17 15:51   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 09/56] scsi: qla2xxx: Add 128-byte IOCB definitions " Nilesh Javali
2026-07-17 15:49   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 10/56] scsi: qla2xxx: Add extended status continuation and marker IOCBs Nilesh Javali
2026-07-17 15:42   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 11/56] scsi: qla2xxx: Update IO path to use 128-byte IOCBs for 29xx Nilesh Javali
2026-07-17 16:13   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 12/56] scsi: qla2xxx: Skip image-set-valid attribute " Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 13/56] scsi: qla2xxx: Skip unsupported sysfs attributes " Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 14/56] scsi: qla2xxx: Enable get_fw_version mailbox " Nilesh Javali
2026-07-17 15:55   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 15/56] scsi: qla2xxx: Extend execute_fw mailbox to include 29xx Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 16/56] scsi: qla2xxx: Enable get_adapter_id mailbox for 29xx Nilesh Javali
2026-07-17 16:00   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 17/56] scsi: qla2xxx: Enable init_firmware " Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 18/56] scsi: qla2xxx: Enable get_firmware_state " Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 19/56] scsi: qla2xxx: Enable serdes, resource count and FCE trace " Nilesh Javali
2026-07-17 16:30   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 20/56] scsi: qla2xxx: Enable set_els_cmds and echo_test " Nilesh Javali
2026-07-17 15:56   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 21/56] scsi: qla2xxx: Add support for QLA29XX in data rate functions Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 22/56] scsi: qla2xxx: Enable qla2x00_shutdown for 29xx Nilesh Javali
2026-07-17 16:01   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 23/56] scsi: qla2xxx: Use ring-slot helpers in __qla2x00_alloc_iocbs Nilesh Javali
2026-07-17 16:03   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 24/56] scsi: qla2xxx: Add support for QLA29XX in memory allocation Nilesh Javali
2026-07-17 16:20   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 25/56] scsi: qla2xxx: Handle sts_cont_entry_ext_t for 29xx adapters Nilesh Javali
2026-07-17 16:11   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 26/56] scsi: qla2xxx: Update handling of status entries for 29xx series Nilesh Javali
2026-07-17 16:20   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 27/56] scsi: qla2xxx: Enhance ct_entry_24xx_ext iocb handling " Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 28/56] scsi: qla2xxx: Enhance purex_entry " Nilesh Javali
2026-07-17 18:29   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 29/56] scsi: qla2xxx: Update handling of ELS IOCBs " Nilesh Javali
2026-07-17 16:17   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 30/56] scsi: qla2xxx: Add size check for ELS status entry layout on 29xx Nilesh Javali
2026-07-17 16:14   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 31/56] scsi: qla2xxx: Add 29xx extended logio IOCB support Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 32/56] scsi: qla2xxx: Enhance task management IOCB handling for 29xx series Nilesh Javali
2026-07-17 18:31   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 33/56] scsi: qla2xxx: Add abort command " Nilesh Javali
2026-07-17 16:42   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 34/56] scsi: qla2xxx: Enhance ABTS processing " Nilesh Javali
2026-07-17 16:49   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 35/56] scsi: qla2xxx: Update VP control IOCB handling " Nilesh Javali
2026-07-17 16:48   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 36/56] scsi: qla2xxx: Add build-time size check for VP config IOCB layout Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 37/56] scsi: qla2xxx: Add size check for extended VP report ID entry Nilesh Javali
2026-07-17 16:29   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 38/56] scsi: qla2xxx: Add LS4 pass-through IOCB handling for 29xx series Nilesh Javali
2026-07-17 16:36   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 39/56] scsi: qla2xxx: Adjust feature gating in BSG paths for 29xx support Nilesh Javali
2026-07-17 16:38   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 40/56] scsi: qla2xxx: Fix queue teardown NULL dma_free and bitmap locking Nilesh Javali
2026-07-17 16:49   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 41/56] scsi: qla2xxx: Replace __le16 bitfields with scalar and accessors Nilesh Javali
2026-07-17 16:46   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 42/56] scsi: qla2xxx: Fix endianness annotations in vp_rpt_id_entry structures Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 43/56] scsi: qla2xxx: Use 64-bit FPM word counters for 29xx host stats Nilesh Javali
2026-07-17 16:28   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 44/56] scsi: qla2xxx: Add 64G/128G port speed setting support Nilesh Javali
2026-07-17 16:32   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 45/56] scsi: qla2xxx: Fix 64G link speed reporting in get_data_rate Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 46/56] scsi: qla2xxx: edif: Fix NULL pointer deref in RX SA delete check Nilesh Javali
2026-07-17 17:37   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 47/56] scsi: qla2xxx: Fix Name Server logout detection on FWI2 adapters Nilesh Javali
2026-07-17 15:28 ` [PATCH v5 48/56] scsi: qla2xxx: Bound VP index against VP_CTRL IOCB bitmap size Nilesh Javali
2026-07-17 16:53   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 49/56] scsi: qla2xxx: Check entry_status in qla24xx_modify_vp_config() Nilesh Javali
2026-07-17 16:59   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 50/56] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition() Nilesh Javali
2026-07-17 17:08   ` sashiko-bot
2026-07-17 15:28 ` [PATCH v5 51/56] scsi: qla2xxx: Initialize NVMe abort_work once at submission Nilesh Javali
2026-07-17 16:45   ` sashiko-bot
2026-07-17 15:29 ` [PATCH v5 52/56] scsi: qla2xxx: Hold qpair lock when sending NVMe LS reject Nilesh Javali
2026-07-17 16:55   ` sashiko-bot
2026-07-17 15:29 ` [PATCH v5 53/56] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Nilesh Javali
2026-07-17 17:10   ` sashiko-bot
2026-07-17 15:29 ` [PATCH v5 54/56] scsi: qla2xxx: Fix BSG job leak on validate flash image error path Nilesh Javali
2026-07-17 16:57   ` sashiko-bot
2026-07-17 15:29 ` [PATCH v5 55/56] scsi: qla2xxx: Bound image count in qla2x00_update_fru_versions() Nilesh Javali
2026-07-17 17:04   ` sashiko-bot
2026-07-17 15:29 ` [PATCH v5 56/56] scsi: qla2xxx: Update version to 12.00.00.2607b1 Nilesh Javali
2026-07-17 16:54   ` 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=20260717155321.56AB61F00A3A@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.