From: sashiko-bot@kernel.org
To: "Chandrakanth Patil" <chandrakanth.patil@broadcom.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 04/17] mpi3mr: Fix target device reference leak in BSG task management
Date: Tue, 18 Aug 2026 18:13:27 +0000 [thread overview]
Message-ID: <20260818181328.01D701F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818231426.58105-5-chandrakanth.patil@broadcom.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free of SCSI target private data (`stgt_priv`) during completion of BSG task management commands if the device is hot-removed.
- [High] Unprotected lockless access to `tgtdev->starget` can lead to a NULL pointer dereference or Use-After-Free.
- [High] Missing bounds validation on the BSG `request_len` allows an Out-of-Bounds read when accessing the variable-length buffer entry list.
- [High] Little-endian `__le16` fields from the user request are assigned to CPU-endian `u16` variables without `le16_to_cpu()` conversion.
--
--- Patch [4]: [PATCH 04/17] mpi3mr: Fix target device reference leak in BSG task management ---
(Note: The format of this review has been altered to a free-form summary due
to automated recitation restrictions. The original patch diff is not quoted.)
commit c103d1267a7a6a9328e7aab3dbe852bbbb68d3e6
Author: Chandrakanth Patil <chandrakanth.patil@broadcom.com>
mpi3mr: Fix target device reference leak in BSG task management
This commit fixes a reference leak for the target device during BSG task
management command processing. The reference is now dropped whenever the
lookup succeeds, regardless of whether the SCSI target data is fully setup.
[Severity: High]
This isn't a bug introduced by this patch, but there appears to be a use
after free risk regarding the SCSI target private data. In
mpi3mr_bsg_process_mpt_cmds(), the block_io counter is incremented on
stgt_priv, and then the target device reference is dropped before sleeping
via wait_for_completion_timeout(). If the target is hot-removed during this
sleep, mpi3mr_target_destroy() will free starget->hostdata. Upon waking,
does the atomic_dec() on stgt_priv->block_io write to freed memory?
[Severity: High]
This is a pre-existing issue, but the access to the target device's starget
pointer seems unprotected. In mpi3mr_bsg_process_mpt_cmds(), tgtdev->starget
is checked for NULL and then dereferenced locklessly to access hostdata.
Since mpi3mr_target_destroy() can concurrently set tgtdev->starget to NULL
under the tgtdev_lock, could this result in a NULL pointer dereference if
the compiler emits multiple loads and the pointer becomes NULL between the
check and the dereference?
[Severity: High]
This isn't a bug introduced by this patch, but there might be an out of
bounds read when iterating over the BSG buffer entries. In
mpi3mr_bsg_process_mpt_cmds(), the loop reads buf_type and buf_len from the
buf_entries list. Is there any validation that the number of entries
provided by the user does not exceed the bounds of the allocated
job->request_len? Could a small request length with a large entry count read
arbitrary slab memory?
[Severity: High]
This is a pre-existing issue, but is there a missing endianness conversion
when parsing the device handle? In mpi3mr_bsg_process_mpt_cmds(),
tm_req->dev_handle is an __le16 field, but it is assigned directly to a u16
local variable without le16_to_cpu(). Similarly,
mpi_header->function_dependent is passed directly to mpi3mr_issue_tm(). On
big-endian architectures, will this block IO on the wrong device and fail
to block IO on the actual target of the task management command?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818231426.58105-1-chandrakanth.patil@broadcom.com?part=4
next prev parent reply other threads:[~2026-08-18 18:13 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 23:14 [PATCH 0/17] mpi3mr: fix out-of-bounds accesses and reference leaks Chandrakanth Patil
2026-08-18 23:14 ` [PATCH 01/17] mpi3mr: Fix buffer overflow in BSG passthrough request copy Chandrakanth Patil
2026-08-18 18:14 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 02/17] mpi3mr: Fix out-of-bounds read when copying BSG MPI requests Chandrakanth Patil
2026-08-18 18:15 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 03/17] mpi3mr: Fix I/O block counter leak on admin request post failure Chandrakanth Patil
2026-08-18 18:11 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 04/17] mpi3mr: Fix target device reference leak in BSG task management Chandrakanth Patil
2026-08-18 18:13 ` sashiko-bot [this message]
2026-08-18 23:14 ` [PATCH 05/17] mpi3mr: Fix buffer overflow when caching log data Chandrakanth Patil
2026-08-18 23:14 ` [PATCH 06/17] mpi3mr: Fix out-of-bounds reply frame access Chandrakanth Patil
2026-08-18 18:11 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 07/17] mpi3mr: Fix out-of-bounds sense buffer access Chandrakanth Patil
2026-08-18 18:11 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 08/17] mpi3mr: Fix out-of-bounds bitmap access during device removal Chandrakanth Patil
2026-08-18 18:13 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 09/17] mpi3mr: Fix target device reference leak in device removal handshake Chandrakanth Patil
2026-08-18 18:18 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 10/17] mpi3mr: Fix out-of-bounds read in SAS topology change events Chandrakanth Patil
2026-08-18 18:10 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 11/17] mpi3mr: Fix out-of-bounds read of event data Chandrakanth Patil
2026-08-18 18:16 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 12/17] mpi3mr: Fix out-of-bounds phy array access on link change Chandrakanth Patil
2026-08-18 18:33 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 13/17] mpi3mr: Fix buffer overflow in the BSG target device map Chandrakanth Patil
2026-08-18 23:14 ` [PATCH 14/17] mpi3mr: Fix out-of-bounds read in PCIe topology change events Chandrakanth Patil
2026-08-18 18:23 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 15/17] mpi3mr: zero out diagnostic buffer status memory Chandrakanth Patil
2026-08-18 18:21 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 16/17] mpi3mr: Fix use-after-free of the firmware event workqueue Chandrakanth Patil
2026-08-18 18:23 ` sashiko-bot
2026-08-18 23:14 ` [PATCH 17/17] mpi3mr: Fix NULL pointer dereference on PCI error recovery Chandrakanth Patil
2026-08-18 18:32 ` 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=20260818181328.01D701F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox