All of lore.kernel.org
 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 v5 2/6] scsi: mvumi: reject an out-of-range handshake frame length
Date: Wed, 14 Oct 2026 15:33:29 +0000	[thread overview]
Message-ID: <sashiko-outbox-171473@kernel.org> (raw)
In-Reply-To: <20261014151914.3632701-3-yhlee@isslab.korea.ac.kr>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: mvumi: TOCTOU on DMA payload bypasses checksum and bounds
- [Medium] scsi: mvumi: missing endianness conversion for frame_length
--

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

scsi: mvumi: reject an out-of-range handshake frame length

This patch fixes an out-of-bounds read and potential hang in the mvumi
driver by validating the frame_length from the handshake page header. It
ensures the length fits within the handshake buffer before calculating the
checksum, and uses READ_ONCE() to prevent the device from changing the
value mid-validation.

> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index 38a92f8c25f5b..2378b676a7a78 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
> @@ -1039,9 +1039,15 @@ static int mvumi_hs_process_page(struct mvumi_hba *mhba,
>  {
>  	struct mvumi_hs_page1 *hs_page1;
>  	unsigned char page_checksum;
> +	u16 frame_length = READ_ONCE(hs_header->frame_length);

[Severity: Medium]
Is an endianness conversion needed here? Hardware devices typically provide
data in little-endian format.

If run on a big-endian architecture, a valid small little-endian length
might be interpreted as a heavily byte-swapped value. This could inevitably
fail the newly added bounds check, preventing driver initialization entirely
on big-endian hosts.

> -	page_checksum = mvumi_calculate_checksum(hs_header,
> -						hs_header->frame_length);
> +	if (frame_length > HSP_MAX_SIZE - sizeof(struct mvumi_hs_header)) {
> +		dev_err(&mhba->pdev->dev, "invalid handshake frame length %d\n",
> +			frame_length);
> +		return -1;
> +	}
> +
> +	page_checksum = mvumi_calculate_checksum(hs_header, frame_length);
>  	if (page_checksum != hs_header->checksum) {
>  		dev_err(&mhba->pdev->dev, "checksum error\n");
>  		return -1;
>  	}

[Severity: High]
Does validating the checksum over the shared DMA buffer guarantee the
payload's integrity when it is read later?

After validation, mvumi_hs_process_page() and mvumi_handshake() read fields
directly from the shared DMA buffer without using READ_ONCE() or making a
local copy:

mvumi_hs_process_page() {
    ...
    switch (hs_header->page_code) {
    case HS_PAGE_FIRM_CAP:
        hs_page1 = (struct mvumi_hs_page1 *) hs_header;
        mhba->max_io = hs_page1->max_io_support;
        ...
        mhba->ib_max_size_setting = hs_page1->cl_in_max_entry_size;
    ...
}

Could a malicious device concurrently modify these fields immediately after
the checksum is verified, bypassing the integrity check entirely?

This might allow the device to inject values that lead to undefined behavior
or severely corrupt the driver state machine.

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

  reply	other threads:[~2026-10-14 15:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 15:19 [PATCH v5 0/6] scsi: mvumi: bound the values the firmware supplies Yehyeong Lee
2026-10-14 15:19 ` [PATCH v5 1/6] scsi: mvumi: bound the per-event parameter and sense dumps Yehyeong Lee
2026-10-14 15:32   ` sashiko-bot
2026-10-14 15:19 ` [PATCH v5 2/6] scsi: mvumi: reject an out-of-range handshake frame length Yehyeong Lee
2026-10-14 15:33   ` sashiko-bot [this message]
2026-10-14 15:19 ` [PATCH v5 3/6] scsi: mvumi: bound the hotplug event bitmap Yehyeong Lee
2026-10-14 15:35   ` sashiko-bot
2026-10-14 15:19 ` [PATCH v5 4/6] scsi: mvumi: reject handshake sizes that overflow the list allocations Yehyeong Lee
2026-10-14 15:31   ` sashiko-bot
2026-10-14 15:19 ` [PATCH v5 5/6] scsi: mvumi: validate the response frame tag before using it Yehyeong Lee
2026-10-14 15:33   ` sashiko-bot
2026-10-14 15:19 ` [PATCH v5 6/6] scsi: mvumi: widen the flush cache loop counter Yehyeong Lee
2026-10-14 15:38   ` sashiko-bot
2026-10-14 16:28 ` [PATCH v5 0/6] scsi: mvumi: bound the values the firmware supplies 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-171473@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 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.