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 v6 28/56] scsi: qla2xxx: Enhance purex_entry handling for 29xx series
Date: Thu, 23 Jul 2026 14:09:48 +0000	[thread overview]
Message-ID: <20260723140948.B53771F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723050413.3897522-29-njavali@marvell.com>

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

New issues:
- [High] The 9-bit virtual port index (`vp_idx`) from 29xx hardware is silently truncated to 8 bits.
- [High] Incorrect response IOCB bitfield corruption for 29xx hardware due to writing via a legacy 24xx struct view.
- [High] Buffer over-read in continuation IOCB parsing on 29xx hardware triggers a FORTIFY_SOURCE panic.

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but a crafted ELS payload containing `0xDEADDEAD` at offset 16 will permanently hang the response queue.
- [High] This problem wasn't introduced by this patch, but `__qla_consume_iocb` consumes an extra, unrelated IOCB and fails to clear the original packet's signature.
- [High] This problem wasn't introduced by this patch, but there is a data race between `atomic_inc_return` and non-atomic `memset` on the default PUREX item.
- [High] This problem wasn't introduced by this patch, but there is an infinite polling loop inside interrupt context causing potential hard lockup.
--

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

This patch updates purex_entry handling to support the 29xx series by
differentiating between standard 64-byte and 128-byte extended structures.
It reuses overlapping byte views to avoid duplicating read paths.

> diff --git a/drivers/scsi/qla2xxx/qla_edif.c b/drivers/scsi/qla2xxx/qla_edif.c
> --- 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)
[ ... ]
> +	uint8_t vp_idx;
> +	struct purex_entry_24xx *p = *pkt;
[ ... ]
> +	if (IS_QLA29XX(ha))
> +		vp_idx = le16_to_cpu(((struct purex_entry_24xx_ext *)
> +				      *pkt)->vp_idx);

[Severity: High]
Does assigning the 16-bit packed vp_idx value to a uint8_t local variable
truncate the 9-bit virtual port index for 29xx hardware? This looks like it
might cause responses for NPIV virtual ports with IDs 256 and above to be
misrouted or dropped.

[ ... ]
> diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
> --- 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,
[ ... ]
>  	entry_count_remaining = purex->entry_count;
>  	while (entry_count_remaining > 0) {
>  		new_pkt = rsp_q->ring_ptr;
>  		*pkt = new_pkt;

[Severity: High]
This is a pre-existing issue, but does __qla_consume_iocb skip the first
packet and over-consume the ring buffer?

The loop executes entry_count times starting from the next packet:

    while (entry_count_remaining > 0) {
        new_pkt = rsp_q->ring_ptr;
        *pkt = new_pkt;

Could this consume and silently drop the next valid IOCB while leaving the
original IOCB signature uncleared?

[ ... ]
> @@ -262,14 +275,24 @@ int __qla_copy_purex_to_buffer(struct scsi_qla_host *vha,
[ ... ]
> +	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);
> +	}

[Severity: High]
Is there a risk of a FORTIFY_SOURCE buffer over-read panic during continuation
IOCB parsing on 29xx hardware?

In __qla_copy_purex_to_buffer and similar functions, the data pointer is
extracted using the sts_cont_entry_t structure:

    data = ((sts_cont_entry_t *)*pkt)->data;
    data_sz = qla_sts_cont_data_size(ha);

Since sts_cont_entry_t->data is statically defined as a 60-byte array,
FORTIFY_SOURCE sets __builtin_object_size to 60. On 29xx hardware, data_sz
returns 124 bytes. Could the subsequent memcpy trigger a panic by attempting
to copy up to 124 bytes from a 60-byte object?

[ ... ]
> @@ -867,6 +891,13 @@ qla27xx_copy_multiple_pkt(struct scsi_qla_host *vha, void **pkt,
[ ... ]
> +	} else if (IS_QLA29XX(ha)) {
> +		purex_ext = *pkt;
> +		total_bytes = (le16_to_cpu(purex_ext->frame_size) & 0x0FFF) -
> +			      PURX_ELS_HEADER_SIZE;

[Severity: High]
This is a pre-existing issue, but can the spin loop in
qla27xx_copy_multiple_pkt cause a hard lockup?

If the hardware fails to provide the next packet, the code executes an
unbounded spin loop in interrupt context:

    if (rsp_q->ring_ptr->signature == RESPONSE_PROCESSED) {
        ql_dbg(...);
        cpu_relax();
        continue;
    }

Could a hardware fault or maliciously crafted entry_count trap the CPU
forever?

[ ... ]
> @@ -1075,9 +1110,9 @@ qla24xx_alloc_purex_item(scsi_qla_host_t *vha, uint16_t size)
[ ... ]
>  	} else {
>  		if (atomic_inc_return(&vha->default_item.in_use) == 1) {
>  			item = &vha->default_item;

[Severity: High]
This is a pre-existing issue, but is there a data race when acquiring the
default PUREX item?

In qla24xx_alloc_purex_item, the code uses atomic_inc_return to acquire the
item:

    if (atomic_inc_return(&vha->default_item.in_use) == 1) {

However, in qla24xx_free_purex_item, the memory is cleared with a non-atomic
memset:

    memset(&item->vha->default_item, 0, sizeof(struct purex_item));

Could two threads simultaneously acquire the default_item if the memset
clears the in_use field while another thread is checking it out?

[ ... ]
> @@ -4151,6 +4201,8 @@ void qla24xx_process_response_queue(struct scsi_qla_host *vha,
[ ... ]
>  		case PUREX_IOCB_TYPE:
> -			purex_entry = (void *)pkt;
> -			switch (purex_entry->els_frame_payload[3]) {
> +			if (IS_QLA29XX(ha)) {
> +				purex_entry_ext = (void *)pkt;

[Severity: High]
This is a pre-existing issue, but can the response queue permanently hang if
a crafted ELS payload contains 0xDEADDEAD at offset 16?

In qla24xx_process_response_queue, the signature field is evaluated to
determine if the hardware has written a new IOCB:

    while (rsp->ring_index != rsp_in &&
           rsp->ring_ptr->signature != RESPONSE_PROCESSED) {

Because the signature field overlaps with bytes 16-19 of the
els_frame_payload, could a malicious payload prematurely terminate the polling
loop and prevent further packets from being processed?

[ ... ]
> 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
> @@ -6209,15 +6211,26 @@ void qla24xx_process_purex_rdp(struct scsi_qla_host *vha,
[ ... ]
> +	if (IS_QLA29XX(ha)) {
> +		vp_idx = le16_to_cpu(
> +		    ((struct purex_entry_24xx_ext *)purex)->vp_idx);
> +		purex_sz = sizeof(struct purex_entry_24xx_ext);

[Severity: High]
Similarly, does extracting the 16-bit vp_idx and storing it in a uint8_t
local variable truncate the value before assigning it to the response IOCB?

[ ... ]
> @@ -6257,7 +6270,7 @@ void qla24xx_process_purex_rdp(struct scsi_qla_host *vha,
>  	rsp_els->handle = 0;
>  	rsp_els->nport_handle = purex->nport_handle;
>  	rsp_els->tx_dsd_count = cpu_to_le16(1);
> -	rsp_els->vp_index = purex->vp_idx;
> +	rsp_els->vp_index = vp_idx;
>  	rsp_els->sof_type = EST_SOFI3;
>  	rsp_els->rx_xchg_address = purex->rx_xchg_addr;

[Severity: High]
Will writing to rsp_els->vp_index and rsp_els->sof_type byte-by-byte corrupt
the packed bitfield on 29xx hardware?

In the 24xx struct view, these are separate bytes, but on 29xx they overlap
with the __le16 vp_idx_sof packed bitfield. Writing EST_SOFI3 to the 8-bit
sof_type could clear the 9th bit of vp_index and set the wrong frame
properties.

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

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

Thread overview: 86+ 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
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  9:26   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 16/56] scsi: qla2xxx: Enable get_adapter_id mailbox for 29xx Nilesh Javali
2026-07-23  9:36   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 17/56] scsi: qla2xxx: Enable init_firmware " Nilesh Javali
2026-07-23  9:45   ` sashiko-bot
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 10:10   ` sashiko-bot
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 10:25   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 22/56] scsi: qla2xxx: Enable qla2x00_shutdown for 29xx Nilesh Javali
2026-07-23 10:34   ` sashiko-bot
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 10:56   ` sashiko-bot
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 11:12   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 26/56] scsi: qla2xxx: Update handling of status entries for 29xx series Nilesh Javali
2026-07-23 13:25   ` sashiko-bot
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 14:09   ` sashiko-bot [this message]
2026-07-23  5:03 ` [PATCH v6 29/56] scsi: qla2xxx: Update handling of ELS IOCBs " Nilesh Javali
2026-07-23 14:25   ` sashiko-bot
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 14:39   ` sashiko-bot
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 15:08   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 33/56] scsi: qla2xxx: Add abort command " Nilesh Javali
2026-07-23 15:28   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 34/56] scsi: qla2xxx: Enhance ABTS processing " Nilesh Javali
2026-07-23 15:53   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 35/56] scsi: qla2xxx: Update VP control IOCB handling " Nilesh Javali
2026-07-23 16:12   ` sashiko-bot
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 16:31   ` sashiko-bot
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 16:47   ` sashiko-bot
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 17:05   ` sashiko-bot
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 17:16   ` sashiko-bot
2026-07-23  5:03 ` [PATCH v6 41/56] scsi: qla2xxx: Replace __le16 bitfields with scalar and accessors Nilesh Javali
2026-07-23 17:29   ` sashiko-bot
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=20260723140948.B53771F000E9@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