From: sashiko-bot@kernel.org
To: "Chandrakanth Patil" <chandrakanth.patil@broadcom.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 02/17] mpi3mr: Fix out-of-bounds read when copying BSG MPI requests
Date: Tue, 25 Aug 2026 16:06:21 +0000 [thread overview]
Message-ID: <20260825160622.28A171F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825210411.301535-3-chandrakanth.patil@broadcom.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing bounds check on BSG request length enables out-of-bounds heap reads.
- [High] Missing endianness conversions on MPI structures cause corruption on big-endian systems.
--
commit ab35632c4adcdd391fb038b2fa77fa3b546f692a
Author: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
mpi3mr: Fix out-of-bounds read when copying BSG MPI requests
The MPI request is copied out of the caller supplied payload without
first checking that the requested amount is actually present, so the
copy can read past the end of the payload buffer. Check the range
before copying.
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_app.c b/drivers/scsi/mpi3mr/mpi3mr_app.c
> index 8e5d24793efd0..1cd1c38dcd565 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_app.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_app.c
> @@ -2538,6 +2538,14 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)
> rval = -EINVAL;
> goto out;
> }
> + if (sgl_iter + mpi_msg_size >
> + dout_buf + job->request_payload.payload_len) {
> + dprint_bsg_err(mrioc, "%s: MPI request buf exceeds dout_buf\n",
> + __func__);
> + mutex_unlock(&mrioc->bsg_cmds.mutex);
> + rval = -EINVAL;
> + goto out;
> + }
[Severity: High]
This is a pre-existing issue, but since this patch fixes bounds checks in
this function, is the initial loop bounded correctly against the user
allocation?
drivers/scsi/mpi3mr/mpi3mr_app.c:mpi3mr_bsg_process_mpt_cmds() {
...
bufcnt = karg->buf_entry_list.num_of_entries;
...
buf_entries = karg->buf_entry_list.buf_entry;
...
for (count = 0; count < bufcnt; count++, buf_entries++, drv_buf_iter++) {
...
}
A user-space process submitting an MPI command via mpi3mr_bsg_request could
provide a small request_len but a large, unchecked
karg->buf_entry_list.num_of_entries.
Does this code overflow buf_entries[] by reading from arbitrary adjacent
heap memory?
[Severity: High]
This isn't a bug introduced by this patch, but does this code cause corruption
on big-endian systems?
drivers/scsi/mpi3mr/mpi3mr_app.c:mpi3mr_bsg_process_mpt_cmds() {
...
dev_handle = tm_req->dev_handle;
...
}
And later in the same function:
drivers/scsi/mpi3mr/mpi3mr_app.c:mpi3mr_bsg_process_mpt_cmds() {
...
status_desc->ioc_status = mrioc->bsg_cmds.ioc_status;
status_desc->ioc_log_info = mrioc->bsg_cmds.ioc_loginfo;
...
}
When an admin issues a SCSI Task Management BSG command, tm_req->dev_handle
(__le16) is directly assigned to dev_handle (u16) without le16_to_cpu(), and
native values are assigned to __le16/__le32 fields without cpu_to_le16/32().
Can this fail the mpi3mr_get_tgtdev_by_handle() lookup and corrupt the
response sent to user-space, bypassing the block_io increment and enabling
unsafe concurrent I/O during target reset?
> memcpy(mpi_req, sgl_iter, mpi_msg_size);
> break;
> default:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260825210411.301535-1-chandrakanth.patil@broadcom.com?part=2
next prev parent reply other threads:[~2026-08-25 16:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 21:03 [PATCH v2 00/17] scsi: mpi3mr: Fix out-of-bounds accesses and reference leaks Chandrakanth Patil
2026-08-25 21:03 ` [PATCH v2 01/17] mpi3mr: Fix buffer overflow in BSG passthrough request copy Chandrakanth Patil
2026-08-25 16:09 ` sashiko-bot
2026-08-25 21:03 ` [PATCH v2 02/17] mpi3mr: Fix out-of-bounds read when copying BSG MPI requests Chandrakanth Patil
2026-08-25 16:06 ` sashiko-bot [this message]
2026-08-25 21:03 ` [PATCH v2 03/17] mpi3mr: Fix I/O block counter leak on admin request post failure Chandrakanth Patil
2026-08-25 16:06 ` sashiko-bot
2026-08-25 21:03 ` [PATCH v2 04/17] mpi3mr: Fix target device reference leak in BSG task management Chandrakanth Patil
2026-08-25 16:05 ` sashiko-bot
2026-08-25 21:03 ` [PATCH v2 05/17] mpi3mr: Fix buffer overflow when caching log data Chandrakanth Patil
2026-08-25 16:12 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 06/17] mpi3mr: Fix out-of-bounds reply frame access Chandrakanth Patil
2026-08-25 21:04 ` [PATCH v2 07/17] mpi3mr: Fix out-of-bounds sense buffer access Chandrakanth Patil
2026-08-25 16:08 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 08/17] mpi3mr: Fix out-of-bounds bitmap access during device removal Chandrakanth Patil
2026-08-25 16:11 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 09/17] mpi3mr: Fix target device reference leak in device removal handshake Chandrakanth Patil
2026-08-25 16:20 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 10/17] mpi3mr: Fix out-of-bounds read in SAS topology change events Chandrakanth Patil
2026-08-25 17:15 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 11/17] mpi3mr: Fix out-of-bounds read of event data Chandrakanth Patil
2026-08-25 16:06 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 12/17] mpi3mr: Fix out-of-bounds phy array access on link change Chandrakanth Patil
2026-08-25 16:18 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 13/17] mpi3mr: Fix buffer overflow in the BSG target device map Chandrakanth Patil
2026-08-25 16:07 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 14/17] mpi3mr: Fix out-of-bounds read in PCIe topology change events Chandrakanth Patil
2026-08-25 16:10 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 15/17] mpi3mr: zero out diagnostic buffer status memory Chandrakanth Patil
2026-08-25 21:04 ` [PATCH v2 16/17] mpi3mr: Fix use-after-free of the firmware event workqueue Chandrakanth Patil
2026-08-25 16:19 ` sashiko-bot
2026-08-25 21:04 ` [PATCH v2 17/17] mpi3mr: Fix NULL pointer dereference on PCI error recovery Chandrakanth Patil
2026-08-25 16:20 ` 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=20260825160622.28A171F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chandrakanth.patil@broadcom.com \
--cc=linux-scsi@vger.kernel.org \
--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.