Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v9 7/9] scsi: mvumi: free the internal command buffer by what was allocated
Date: Thu, 15 Oct 2026 05:03:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-172292@kernel.org> (raw)
In-Reply-To: <20261015045213.3975845-8-yhlee@isslab.korea.ac.kr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: mvumi: DMA Use-After-Free on internal command timeout
--

commit a045f4b7ba7499dba25350d8e9d333f7c9956722
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

scsi: mvumi: free the internal command buffer by what was allocated
    
This patch stores the DMA buffer address and length directly in the
mvumi_cmd struct instead of reconstructing it from the command frame.
This avoids an issue where a 32-bit shift in mvumi_delete_internal_cmd()
caused the upper 32 bits of the DMA address to be truncated.

> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index 2410d2aa147d9..133e53bc2cb37 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
[ ... ]
> @@ -286,21 +288,10 @@ static struct mvumi_cmd *mvumi_create_internal_cmd(struct mvumi_hba *mhba,
>  static void mvumi_delete_internal_cmd(struct mvumi_hba *mhba,
>  						struct mvumi_cmd *cmd)
>  {
> -	struct mvumi_sgl *m_sg;
> -	unsigned int size;
> -	dma_addr_t phy_addr;
> -
>  	if (cmd && cmd->frame) {
> -		if (cmd->frame->sg_counts) {
> -			m_sg = (struct mvumi_sgl *) &cmd->frame->payload[0];
> -			sgd_getsz(mhba, m_sg, size);
> -
> -			phy_addr = (dma_addr_t) m_sg->baseaddr_l |
> -				(dma_addr_t) ((m_sg->baseaddr_h << 16) << 16);
> -
> -			dma_free_coherent(&mhba->pdev->dev, size, cmd->data_buf,
> -								phy_addr);
> -		}
> +		if (cmd->data_buf)
> +			dma_free_coherent(&mhba->pdev->dev, cmd->data_buf_size,
> +					  cmd->data_buf, cmd->data_buf_phys);

[Severity: High]
If an internal command times out in mvumi_issue_blocked_cmd(), the function
returns without explicitly aborting the hardware operation or resetting the
controller.

The callers of mvumi_issue_blocked_cmd() (such as mvumi_inquiry(),
mvumi_flush_cache(), or mvumi_scan_events()) then immediately invoke
mvumi_delete_internal_cmd(), which unconditionally frees the DMA-mapped
command frame and data buffer back to the system.

Since the hardware is unaware that the software has abandoned the command,
can a delayed completion cause the hardware to write to the freed physical
memory, resulting in a DMA use-after-free and memory corruption?

>  		dma_free_coherent(&mhba->pdev->dev, mhba->ib_max_size,
>  				cmd->frame, cmd->frame_phys);
>  		kfree(cmd);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261015045213.3975845-1-yhlee@isslab.korea.ac.kr?part=7

  reply	other threads:[~2026-10-15  5:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  4:52 [PATCH v9 0/9] scsi: mvumi: bound the values the firmware supplies Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 1/9] scsi: mvumi: bound the per-event parameter and sense dumps Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 2/9] scsi: mvumi: reject an out-of-range handshake frame length Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 3/9] scsi: mvumi: bound the hotplug event bitmap Yehyeong Lee
2026-10-15  5:08   ` sashiko-bot
2026-10-15  4:52 ` [PATCH v9 4/9] scsi: mvumi: walk the hotplug event bitmap a byte at a time Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 5/9] scsi: mvumi: reject handshake sizes that overflow the list allocations Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 6/9] scsi: mvumi: validate the response frame tag before using it Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 7/9] scsi: mvumi: free the internal command buffer by what was allocated Yehyeong Lee
2026-10-15  5:03   ` sashiko-bot [this message]
2026-10-15  5:57     ` Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 8/9] scsi: mvumi: stamp a consumed outbound list entry out of range Yehyeong Lee
2026-10-15  4:52 ` [PATCH v9 9/9] scsi: mvumi: bound the firmware handshake retry loop Yehyeong Lee

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=sashiko-outbox-172292@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yhlee@isslab.korea.ac.kr \
    /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