Linux SCSI subsystem development
 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 v4 28/56] scsi: qla2xxx: Enhance purex_entry handling for 29xx series
Date: Tue, 14 Jul 2026 14:45:33 +0000	[thread overview]
Message-ID: <20260714144534.709391F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260714095353.289460-29-njavali@marvell.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

New issues:
- [Critical] Incomplete fix for FORTIFY_SOURCE buffer limits in continuation IOCBs on QLA29xx adapters, leading to guaranteed kernel panics on multi-IOCB frames.
- [Medium] Silent truncation of the 16-bit Virtual Port (VP) index to 8 bits, breaking >255 VP support on 29xx adapters.

Pre-existing issues:
- [Critical] `__qla_consume_iocb` incorrectly loops `entry_count` times without accounting for the already-consumed head IOCB, skipping the head signature and discarding unrelated IOCBs.
--

--- Patch [28]: [PATCH v4 28/56] scsi: qla2xxx: Enhance purex_entry handling for 29xx series ---
commit 91252616a5e800941a18bc247ce6eecf4c680a85
Author: Nilesh Javali <njavali@marvell.com>

scsi: qla2xxx: Enhance purex_entry handling for 29xx series

This updates function signatures and internal logic across multiple files
to accept a generic pointer for packet data. It differentiates between
standard purex_entry_24xx and extended purex_entry_24xx_ext structures
based on the IS_QLA29XX() macro to support 64-byte and 128-byte IOCBs.

> diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
> index b05f8e0b705ee..ade1d81785736 100644
> --- a/drivers/scsi/qla2xxx/qla_edif.c
> +++ b/drivers/scsi/qla2xxx/qla_edif.c
> @@ -2544,26 +2544,55 @@ void qla24xx_auth_els(scsi_qla_host_t *vha, void **pkt, struct rsp_que **rsp)
>  	struct fc_port *fcport;
>  	struct qla_els_pt_arg a;
>  	be_id_t beid;
> +	__le16 nport_handle;
> +	__le32 rx_xchg_addr;
> +	__le16 ox_id;
> +	__le16 frame_size, status_flags, trunc_frame_size;
> +	uint8_t s_id[3], d_id[3];
> +	uint8_t vp_idx;
> +	struct purex_entry_24xx *p = *pkt;
>  
>  	memset(&a, 0, sizeof(a));
>  
> +	/*
> +	 * purex_entry_24xx_ext (29xx) overlays purex_entry_24xx for every
> +	 * field touched here -- nport_handle, rx_xchg_addr, ox_id, frame_size,
> +	 * status_flags, trunc_frame_size, s_id[3], d_id[3] -- with only
> +	 * vp_idx differing in width (u8 at offset 6 vs __le16 at offsets 6-7,
> +	 * with reserved2 at offset 7 in the 24xx layout). So all reads but
> +	 * vp_idx go through a single struct purex_entry_24xx * view.
> +	 */
> +	nport_handle = p->nport_handle;
> +	rx_xchg_addr = p->rx_xchg_addr;
> +	ox_id = p->ox_id;
> +	frame_size = p->frame_size;
> +	status_flags = p->status_flags;
> +	trunc_frame_size = p->trunc_frame_size;
> +	memcpy(s_id, p->s_id, sizeof(s_id));
> +	memcpy(d_id, p->d_id, sizeof(d_id));
> +	if (IS_QLA29XX(ha))
> +		vp_idx = le16_to_cpu(((struct purex_entry_24xx_ext *)
> +				      *pkt)->vp_idx);
> +	else
> +		vp_idx = p->vp_idx;

[Severity: Medium]
Can this silently truncate the virtual port index on 29xx adapters?

The 29xx extended structure defines a 16-bit vp_idx to support 9 bits of
virtual port index data. However, the value is being stored in the new
uint8_t vp_idx local variable in both qla24xx_auth_els() and
qla24xx_process_purex_rdp(). Does this break support for setups with more
than 255 NPIV vports by silently discarding the upper bits?

Additionally, when qla24xx_process_purex_rdp() populates the response
IOCB later on, writing the 8-bit vp_idx and sof_type into rsp_els
overwrites offsets 14 and 15 individually. Could this corrupt the 9th bit
of the __le16 vp_idx_sof union expected by the 29xx firmware?

[ ... ]

> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
> index c38771e4202c0..c4e2e62f924ff 100644
> --- a/drivers/scsi/qla2xxx/qla_isr.c
> +++ b/drivers/scsi/qla2xxx/qla_isr.c
> @@ -202,6 +202,11 @@ void __qla_consume_iocb(struct scsi_qla_host *vha,
>  	struct rsp_que *rsp_q = *rsp;
>  	response_t *new_pkt;
>  	uint16_t entry_count_remaining;
> +	/*
> +	 * entry_count is u8 at offset 1 in both purex_entry_24xx and
> +	 * purex_entry_24xx_ext, so the 24xx view is layout-compatible with
> +	 * either stride.
> +	 */
>  	struct purex_entry_24xx *purex = *pkt;
>  
>  	entry_count_remaining = purex->entry_count;
> @@ -230,6 +235,14 @@ void __qla_consume_iocb(struct scsi_qla_host *vha,
>  		new_pkt = rsp_q->ring_ptr;
>  		*pkt = new_pkt;

[Severity: Critical]
This is a pre-existing issue, but does this loop correctly handle the head
IOCB?

In __qla_consume_iocb(), the while loop processes entry_count_remaining
items by advancing the ring pointer and marking new_pkt as
RESPONSE_PROCESSED. Because qla24xx_process_response_queue() has already
advanced the ring pointer over the head IOCB before calling this function,
this loop appears to leave the head IOCB's signature unmarked.

Consequently, it looks like it will consume and discard unrelated subsequent
IOCBs by looping entry_count times from the already-advanced position. Could
this lead to response ring corruption or a permanent queue stall when the
ring wraps around and hits the unmarked head IOCB?

[ ... ]

> @@ -262,14 +275,24 @@ int __qla_copy_purex_to_buffer(struct scsi_qla_host *vha,
>  	}
>  
>  	pending_bytes = total_bytes = tpad;
> -	no_bytes = (pending_bytes > sizeof(purex->els_frame_payload))  ?
> -	    sizeof(purex->els_frame_payload) : pending_bytes;
> +	no_bytes = (pending_bytes > payload_size) ?
> +		payload_size : pending_bytes;
> +	if (IS_QLA29XX(ha)) {
> +		struct purex_entry_24xx_ext *purex_ext = *pkt;
>  
> -	memcpy(buf, &purex->els_frame_payload[0], no_bytes);
> +		memcpy(buf, &purex_ext->els_frame_payload[0], no_bytes);
> +	} else {
> +		memcpy(buf, &purex->els_frame_payload[0], no_bytes);
> +	}
>  	buffer_copy_offset += no_bytes;
>  	pending_bytes -= no_bytes;
>  	--entry_count_remaining;

[Severity: Critical]
Will the continuation IOCB extraction loops trigger a fortify source panic
on 29xx adapters?

Further down in __qla_copy_purex_to_buffer() (and similarly in the loops
for qla27xx_copy_multiple_pkt(), qla27xx_copy_fpin_pkt(), and
qla2x00_status_cont_entry()), the code casts the packet to sts_cont_entry_t,
which defines data as a 60-byte array:

    data = ((sts_cont_entry_t *)*pkt)->data;
    data_sz = qla_sts_cont_data_size(ha);
    ...
    memcpy((buf + buffer_copy_offset), data, no_bytes);

However, on 29xx adapters, data_sz can be up to 124 bytes. When memcpy()
attempts to copy up to 124 bytes from a struct member declared as a 60-byte
array, won't this trigger a __read_overflow2_field panic when processing
multi-IOCB PUREX, PURLS, or FPIN frames?

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

  reply	other threads:[~2026-07-14 14:45 UTC|newest]

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