All of lore.kernel.org
 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 v4 2/3] ALSA: bebob: bound the stream format entries to the response length
Date: Sat, 05 Dec 2026 17:23:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-251764@kernel.org> (raw)
In-Reply-To: <20261206-firewire-avc-bounds-v4-2-d90e91e0088e@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 d3d080432ed80d2e85b65474995acaba610e99c9
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() so that the
stream format entries counted by buf[4] are validated against len before
the parsing loop runs.

> 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]
Does parse_stream_formation() still read buf[0..2] before checking len?

avc_bridgeco_get_plug_strm_fmt() accepts FCP responses down to 12 bytes,
shifts the payload with memmove(buf, buf + 11, err - 11), and sets
*len = err - 11.

For a 12- or 13-byte response (len of 1 or 2), parse_stream_formation()
reads stale AV/C header bytes in buf[1] or buf[2] past len and returns
-ENOSYS instead of -EIO, making the new len < 5 check unreachable for
len <= 2.

Checking len < 5 before inspecting buf[0..2] would avoid reading past
len and return -EIO consistently for truncated responses.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-firewire-avc-bounds-v4-0-d90e91e0088e@gmail.com?part=2

  reply	other threads:[~2026-12-05 17:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 17:14 [PATCH v4 0/3] ALSA: bebob/oxfw: bound AV/C response walks to the response length Maoyi Xie via B4 Relay
2026-12-05 17:14 ` Maoyi Xie
2026-12-05 17:14 ` [PATCH v4 1/3] ALSA: bebob: bound the channel position walk " Maoyi Xie via B4 Relay
2026-12-05 17:14   ` Maoyi Xie
2026-12-05 17:14 ` [PATCH v4 2/3] ALSA: bebob: bound the stream format entries " Maoyi Xie via B4 Relay
2026-12-05 17:14   ` Maoyi Xie
2026-12-05 17:23   ` sashiko-bot [this message]
2026-12-05 17:14 ` [PATCH v4 3/3] ALSA: oxfw: " Maoyi Xie via B4 Relay
2026-12-05 17:14   ` Maoyi Xie
2026-12-05 17:29   ` 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-251764@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 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.