From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 53/56] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak
Date: Thu, 23 Jul 2026 19:49:57 +0000 [thread overview]
Message-ID: <20260723194957.9E7B01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723050413.3897522-54-njavali@marvell.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Multiple BSG handlers use uninitialized stack buffers for request/reply structures, causing kernel memory leaks, arbitrary hardware writes, and severe buffer overflows when users provide a short payload.
- [High] Modifying a DMA buffer with memset() after it has been mapped for DMA_FROM_DEVICE violates DMA ownership rules and causes cache coherency data corruption.
- [High] DMA mapping a misaligned buffer inside a __packed struct risks cache line sharing corruption and hardware DMA faults.
- [Medium] Unvalidated reply_payload_rcv_len can trigger a kernel WARN_ON in the block layer.
--
--- Patch [53]: [PATCH v6 53/56] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak ---
commit b2d4e000f67ba62a27fd752863bb10d9c1b2ea09
Author: Nilesh Javali <njavali@marvell.com>
scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak
This patch changes the allocation of the qla_dport_diag response buffer
from kmalloc_obj() to kzalloc_obj() in qla2x00_do_dport_diagnostics().
The change ensures the buffer is zero-initialized, preventing kernel heap
contents from leaking to user space when copying the structure back.
> diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
> index f9f9687316b58..4a9cf8da67a6b 100644
> --- a/drivers/scsi/qla2xxx/qla_bsg.c
> +++ b/drivers/scsi/qla2xxx/qla_bsg.c
> @@ -2806,7 +2806,7 @@ qla2x00_do_dport_diagnostics(struct bsg_job *bsg_job)
> !IS_QLA28XX(vha->hw) && !IS_QLA29XX(vha->hw))
> return -EPERM;
>
> - dd = kmalloc_obj(*dd);
> + dd = kzalloc_obj(*dd);
[Severity: High]
This is a pre-existing issue, but are we risking cache line sharing
corruption and hardware DMA faults by DMA mapping the misaligned buffer
inside this structure?
Looking at the structure definition:
drivers/scsi/qla2xxx/qla_bsg.h:struct qla_dport_diag {
uint16_t options;
uint32_t buf[16];
uint8_t unused[62];
} __packed;
Because the struct is __packed, the buf array is forced to an unaligned
2-byte offset.
When buf is subsequently mapped for DMA in qla26xx_dport_diagnostics():
drivers/scsi/qla2xxx/qla_mbx.c:qla26xx_dport_diagnostics() {
...
dd_dma = dma_map_single(&vha->hw->pdev->dev, dd_buf, size,
DMA_FROM_DEVICE);
...
}
Could unmapping or syncing this misaligned buffer on non-coherent
architectures invalidate the entire cache line, thereby corrupting the
adjacent options and unused fields? Furthermore, could providing a 2-byte
aligned address to the HBA cause hardware DMA faults?
[Severity: High]
This isn't a bug introduced by this patch, but does the memset() in the
diagnostics functions violate DMA ownership rules?
In qla26xx_dport_diagnostics():
drivers/scsi/qla2xxx/qla_mbx.c:qla26xx_dport_diagnostics() {
...
dd_dma = dma_map_single(&vha->hw->pdev->dev, dd_buf, size,
DMA_FROM_DEVICE);
...
memset(dd_buf, 0, size);
...
}
A similar pattern exists in qla26xx_dport_diagnostics_v2().
The DMA API forbids the CPU from modifying a buffer while it is mapped for
device DMA. On non-cache-coherent architectures, does the CPU write bring
the cache line into the CPU cache and mark it as dirty, meaning that if it
is evicted to RAM after the device completes its DMA writes, the CPU's
zeroes might silently overwrite the device's diagnostic data?
Since the allocation in qla2x00_do_dport_diagnostics() is now using
kzalloc_obj(), is this memset() still necessary, or can it be removed?
[Severity: Medium]
This is a pre-existing issue, but does setting the reply length
unconditionally risk triggering a block layer WARN_ON if the user provides
a short payload?
Later in qla2x00_do_dport_diagnostics():
drivers/scsi/qla2xxx/qla_bsg.c:qla2x00_do_dport_diagnostics() {
...
bsg_reply->reply_payload_rcv_len = sizeof(*dd);
...
}
If a user submits a BSG job with a reply payload smaller than sizeof(*dd),
will reply_payload_rcv_len exceed the allocated response length, triggering
a WARN_ON(job->reply_payload_rcv_len > rsp_len) in the block layer?
[Severity: Critical]
This is a pre-existing issue, but do other BSG handlers have similar
uninitialized stack buffer vulnerabilities?
Several handlers allocate structures on the stack without initializing them,
and sg_copy_to_buffer() only populates the bytes provided by the user
payload. If a user provides a short payload, variables might remain
uninitialized stack garbage.
For example, in qla2x00_write_i2c():
drivers/scsi/qla2xxx/qla_bsg.c:qla2x00_write_i2c() {
...
memcpy(sfp, i2c->buffer, i2c->length);
...
}
Could an uninitialized i2c->length cause an out-of-bounds read from the
stack and an out-of-bounds write to the DMA pool allocation?
Similar issues appear to exist in:
- qla2x00_read_i2c() (memcpy overflowing the fixed-size stack array bsg)
- qla2x00_update_fru_versions() (uninitialized list->count dictating loop
iterations)
- qla2x00_read_fru_status() (uninitialized stack buffer copied to user space)
- qla_edif_app_start() (uninitialized pad and reserved fields copied to
user space)
Could a user issuing a BSG job with a truncated request payload trigger
these out-of-bounds accesses or memory leaks?
> if (!dd) {
> ql_log(ql_log_warn, vha, 0x70db,
> "Failed to allocate memory for dport.\n");
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723050413.3897522-1-njavali@marvell.com?part=53
next prev parent reply other threads:[~2026-07-23 19:49 UTC|newest]
Thread overview: 96+ 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
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 18:07 ` sashiko-bot
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 18:17 ` sashiko-bot
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 18:56 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 50/56] scsi: qla2xxx: Hold vport reference in qla24xx_report_id_acquisition() Nilesh Javali
2026-07-23 19:12 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 51/56] scsi: qla2xxx: Initialize NVMe abort_work once at submission Nilesh Javali
2026-07-23 19:26 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 52/56] scsi: qla2xxx: Hold qpair lock when sending NVMe LS reject Nilesh Javali
2026-07-23 19:36 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 53/56] scsi: qla2xxx: Zero dport diagnostics buffer to avoid info leak Nilesh Javali
2026-07-23 19:49 ` sashiko-bot [this message]
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 20:05 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 55/56] scsi: qla2xxx: Bound image count in qla2x00_update_fru_versions() Nilesh Javali
2026-07-23 20:16 ` sashiko-bot
2026-07-23 5:04 ` [PATCH v6 56/56] scsi: qla2xxx: Update version to 12.00.00.2607b1 Nilesh Javali
2026-07-23 20:27 ` 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=20260723194957.9E7B01F000E9@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