From: sashiko-bot@kernel.org
To: "Michael Bommarito" <michael.bommarito@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: core: bound the VPD page 0x83 designator walk
Date: Sat, 11 Jul 2026 15:14:37 +0000 [thread overview]
Message-ID: <20260711151437.DC0711F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260711150718.2916641-1-michael.bommarito@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing descriptor payload length check in `scsi_vpd_tpg_id()` leads to an out-of-bounds read when accessing `d[6]` and `d[7]`.
--
--- Patch [1]: [PATCH] scsi: core: bound the VPD page 0x83 designator walk ---
commit 390f380557d52bf9b1b813ffda5cbf376ee027a2
Author: Michael Bommarito <michael.bommarito@gmail.com>
scsi: core: bound the VPD page 0x83 designator walk
This commit fixes an out-of-bounds read in the VPD page 0x83 designator
walk by ensuring the designator length does not exceed the remaining bytes
in the page. It updates scsi_vpd_lun_id(), scsi_vpd_tpg_id(), and
sd_get_unique_id() to bound each iteration.
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
[ ... ]
> @@ -3546,8 +3554,14 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id)
> return -ENXIO;
> }
>
> - d = vpd_pg83->data + 4;
> - while (d < vpd_pg83->data + vpd_pg83->len) {
> + for (off = 4; off < vpd_pg83->len; off += d[3] + 4) {
> + if (vpd_pg83->len - off < 4)
> + break;
> +
> + d = vpd_pg83->data + off;
> + if (d[3] > vpd_pg83->len - off - 4)
> + break;
> +
> switch (d[1] & 0xf) {
> case 0x4:
> /* Relative target port */
> rel_port = get_unaligned_be16(&d[6]);
> break;
> case 0x5:
> /* Target port group */
> group_id = get_unaligned_be16(&d[6]);
> break;
[Severity: High]
This is a pre-existing issue, but can this code read out of bounds if the
designator payload length is less than 4?
In scsi_vpd_tpg_id(), the switch statement unconditionally reads d[6] and d[7]
via get_unaligned_be16 without verifying that the designator length (d[3]) is
at least 4.
If a device or untrusted hypervisor backend provides a VPD page 0x83 containing
a designator with type 0x4 or 0x5 and a declared length (d[3]) of less than 4,
and this designator is positioned at the very end of the buffer, could the
fixed-offset read at &d[6] access memory out of bounds?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711150718.2916641-1-michael.bommarito@gmail.com?part=1
next prev parent reply other threads:[~2026-07-11 15:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 15:07 [PATCH] scsi: core: bound the VPD page 0x83 designator walk Michael Bommarito
2026-07-11 15:14 ` sashiko-bot [this message]
2026-07-11 15:38 ` James Bottomley
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=20260711151437.DC0711F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=michael.bommarito@gmail.com \
--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.