From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v6 3/5] scsi: mvumi: bound the hotplug event bitmap
Date: Wed, 14 Oct 2026 16:39:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-171547@kernel.org> (raw)
In-Reply-To: <20261014162413.3649841-4-yhlee@isslab.korea.ac.kr>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: mvumi: unaligned memory access in find_next_zero_bit()
- [High] scsi: mvumi: unaligned bitmap access and overlap in hotplug event
--
commit 858b7c6c7bb4515208e9ef60baca2c850663e824
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
scsi: mvumi: bound the hotplug event bitmap
This commit bounds the hotplug event bitmap to prevent the firmware from
reading past the event buffer. It checks the hotplug event size against
the expected structure length.
> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index 2378b676a7a78..9a3dde53dea97 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
> @@ -1652,11 +1652,25 @@ static int mvumi_rescan_bus(void *data)
> static void mvumi_proc_msg(struct mvumi_hba *mhba,
> struct mvumi_hotplug_event *param)
> {
> - u16 size = param->size;
> + u16 size = READ_ONCE(param->size);
> const unsigned long *ar_bitmap;
> const unsigned long *re_bitmap;
> int index;
>
> + /*
> + * The second bitmap starts size bits into the event buffer and
> + * find_next_zero_bit() reads it a long at a time, so that is the
> + * furthest the two scans reach. Bound it by the length the firmware
> + * was told it may write, not by the buffer: the bytes past that are
> + * still zero, and a zero bit here means a device is present.
> + */
> + if (sizeof(*param) + (size >> 3) + BITS_TO_LONGS(size) * sizeof(long) >
> + sizeof(struct mvumi_event_req)) {
[Severity: High]
Does this code introduce an unaligned memory access and potential overlap
between bitmaps?
Looking at struct mvumi_hotplug_event, the bitmap array sits at a 4-byte
offset:
drivers/scsi/mvumi.h:
struct mvumi_hotplug_event {
u16 size;
u8 dummy[2];
u8 bitmap[];
};
Since param->bitmap sits at a 4-byte offset within the DMA buffer, casting it
to unsigned long * and passing it to find_next_zero_bit() in mvumi_proc_msg()
will cause an alignment fault on strict-alignment 64-bit architectures.
Additionally, if the firmware provides a size that is not a multiple of 8,
does the size >> 3 offset truncate the remainder?
If truncated, re_bitmap will overlap with ar_bitmap's memory, which might
cause the same bits to be scanned for both device additions and removals.
This new bounds check explicitly relies on the size >> 3 offset without
accounting for the unaligned access or overlap.
> + dev_err(&mhba->pdev->dev,
> + "invalid hotplug event bitmap size %u\n", size);
> + return;
> + }
> +
> if (mhba->fw_flag & MVUMI_FW_ATTACH) {
> index = -1;
> ar_bitmap = (const unsigned long *) param->bitmap;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261014162413.3649841-1-yhlee@isslab.korea.ac.kr?part=3
next prev parent reply other threads:[~2026-10-14 16:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-14 16:24 [PATCH v6 0/5] scsi: mvumi: bound the values the firmware supplies Yehyeong Lee
2026-10-14 16:24 ` [PATCH v6 1/5] scsi: mvumi: bound the per-event parameter and sense dumps Yehyeong Lee
2026-10-14 16:24 ` [PATCH v6 2/5] scsi: mvumi: reject an out-of-range handshake frame length Yehyeong Lee
2026-10-14 16:24 ` [PATCH v6 3/5] scsi: mvumi: bound the hotplug event bitmap Yehyeong Lee
2026-10-14 16:39 ` sashiko-bot [this message]
2026-10-14 16:24 ` [PATCH v6 4/5] scsi: mvumi: reject handshake sizes that overflow the list allocations Yehyeong Lee
2026-10-14 16:40 ` sashiko-bot
2026-10-14 16:24 ` [PATCH v6 5/5] scsi: mvumi: validate the response frame tag before using it Yehyeong Lee
2026-10-14 16:40 ` 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=sashiko-outbox-171547@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