Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maoyi Xie" <maoyixie.tju@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v3 2/4] ALSA: bebob: bound the stream format entries to the response length
Date: Wed, 02 Dec 2026 07:15:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-245039@kernel.org> (raw)
In-Reply-To: <20261202070452.732525-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 fdc1d8bd20b16e5b19616e6a041bb9876894ff4c
Author: Maoyi Xie <maoyixie.tju@gmail.com>

ALSA: bebob: bound the stream format entries to the response length

This commit checks that the stream format entry count in buf[4] fits
within the response length in parse_stream_formation().

> 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 length check come at the start of parse_stream_formation(),
before buf[0], buf[1], and buf[2] are read?

avc_bridgeco_get_plug_strm_fmt() accepts FCP responses of 12 bytes or
more and shifts err - 11 bytes to the start of buf, so len can be 1..4.
Because parse_stream_formation() checks buf[0..2] first:

sound/firewire/bebob/bebob_stream.c:parse_stream_formation() {
    ...
	if ((buf[0] != 0x90) || (buf[1] != 0x40))
		return -ENOSYS;

	/* check sampling rate */
	for (i = 0; i < ARRAY_SIZE(bridgeco_freq_table); i++) {
		if (buf[2] == bridgeco_freq_table[i])
			break;
	}
    ...
}

when len is 1 or 2, reading buf[1] and buf[2] accesses bytes past the
response length (stale FCP request header bytes in
fill_stream_formations(), or out of bounds if a caller passes a buffer
sized to len) and returns -ENOSYS instead of -EIO.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202070452.732525-1-maoyixie.tju@gmail.com?part=2

  reply	other threads:[~2026-12-02  7:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:04 [PATCH v3 0/4] ALSA: bebob/oxfw: bound AV/C response walks to the response length Maoyi Xie
2026-12-02  7:04 ` [PATCH v3 1/4] ALSA: bebob: bound the channel position walk " Maoyi Xie
2026-12-02  7:04 ` [PATCH v3 2/4] ALSA: bebob: bound the stream format entries " Maoyi Xie
2026-12-02  7:15   ` sashiko-bot [this message]
2026-12-02  7:04 ` [PATCH v3 3/4] ALSA: oxfw: " Maoyi Xie
2026-12-02  7:04 ` [PATCH v3 4/4] ALSA: oxfw: bound the current " 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-245039@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