From: sashiko-bot@kernel.org
To: "Maoyi Xie" <maoyixie.tju@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v2 2/3] ALSA: bebob: bound the stream format entries to the response length
Date: Mon, 30 Nov 2026 10:59:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-240904@kernel.org> (raw)
In-Reply-To: <20261130104949.2216908-3-maoyixie.tju@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ALSA: bebob: parse_stream_formation() reads buf[0..2] before
checking len
--
commit 560d5849ef69c1f47cc89934fe0f676a913fc19b
Author: Maoyi Xie <maoyixie.tju@gmail.com>
ALSA: bebob: bound the stream format entries to the response length
This commit adds a length check in parse_stream_formation() to ensure the
stream format entries fit within the response buffer.
> diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
> index 5850357cb3dad..8eceafc70a447 100644
> --- a/sound/firewire/bebob/bebob_stream.c
> +++ b/sound/firewire/bebob/bebob_stream.c
> @@ -730,6 +730,10 @@ parse_stream_formation(u8 *buf, unsigned int len,
> if (i == ARRAY_SIZE(bridgeco_freq_table))
> return -ENOSYS;
>
> + /* The entries should be within the response. */
> + if (len < 5 || len < 5 + buf[4] * 2)
> + return -EIO;
[Severity: Medium]
Should the len < 5 check come before buf[0], buf[1], and buf[2] are read
at the start of parse_stream_formation()?
avc_bridgeco_get_plug_strm_fmt() accepts FCP responses of 12 bytes or
more and shifts err - 11 bytes to the start of buf:
sound/firewire/bebob/bebob_command.c:avc_bridgeco_get_plug_strm_fmt() {
...
else if (err < 12)
err = -EIO;
...
memmove(buf, buf + 11, err - 11);
*len = err - 11;
...
}
When a short response leaves len < 5, parse_stream_formation() reads
buf[0..2] before checking len. For len <= 2, buf[1] or buf[2] still
holds leftover bytes from the 12-byte request header (0xff and 0x2f),
which do not match 0x40 or bridgeco_freq_table[] and cause an early
-ENOSYS return instead of -EIO.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130104949.2216908-1-maoyixie.tju@gmail.com?part=2
next prev parent reply other threads:[~2026-11-30 10:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 10:49 [PATCH v2 0/3] ALSA: bebob/oxfw: bound AV/C response walks to the response length Maoyi Xie
2026-11-30 10:49 ` [PATCH v2 1/3] ALSA: bebob: bound the channel position walk " Maoyi Xie
2026-11-30 10:49 ` [PATCH v2 2/3] ALSA: bebob: bound the stream format entries " Maoyi Xie
2026-11-30 10:59 ` sashiko-bot [this message]
2026-11-30 10:49 ` [PATCH v2 3/3] ALSA: oxfw: " Maoyi Xie
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-240904@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=maoyixie.tju@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox