From: sashiko-bot@kernel.org
To: "Maoyi Xie" <maoyixie.tju@gmail.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH v4 3/3] ALSA: oxfw: bound the stream format entries to the response length
Date: Sat, 05 Dec 2026 17:29:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-251767@kernel.org> (raw)
In-Reply-To: <20261206-firewire-avc-bounds-v4-3-d90e91e0088e@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ALSA: oxfw: duplicate AM824 parsing logic in
check_and_parse_format()
--
commit 09d04fde4586e79a8721a40f8fc2146df6f65643
Author: Maoyi Xie <maoyixie.tju@gmail.com>
ALSA: oxfw: bound the stream format entries to the response length
This commit splits stream format parsing into check_and_parse_format(),
which checks that the two-byte format entries fit within the response
length for live responses, and snd_oxfw_stream_parse_format(), which
parses cached formats.
> diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
> index 5e36d7153a7b6..cc61ad1ee3071 100644
> --- a/sound/firewire/oxfw/oxfw-stream.c
> +++ b/sound/firewire/oxfw/oxfw-stream.c
[ ... ]
> @@ -548,8 +551,8 @@ int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw,
> * in AV/C Stream Format Information Specification 1.1 (Apr 2005, 1394TA)
> * Also 'Clause 12 AM824 sequence adaption layers' in IEC 61883-6:2005
> */
> -int snd_oxfw_stream_parse_format(const u8 *format,
> - struct snd_oxfw_stream_formation *formation)
> +static int check_and_parse_format(const u8 *format, unsigned int len,
> + struct snd_oxfw_stream_formation *formation)
> {
> unsigned int i, e, channels, type;
>
> @@ -563,6 +566,10 @@ int snd_oxfw_stream_parse_format(const u8 *format,
> if ((format[0] != 0x90) || (format[1] != 0x40))
> return -ENXIO;
>
> + /* The entries should be within the response. */
> + if (len < 5 || len < 5 + format[4] * 2)
> + return -EIO;
> +
> /* check the sampling rate */
> for (i = 0; i < ARRAY_SIZE(avc_stream_rate_table); i++) {
> if (format[2] == avc_stream_rate_table[i])
> @@ -624,6 +631,36 @@ int snd_oxfw_stream_parse_format(const u8 *format,
> return 0;
> }
>
> +/* The cached formats were checked by check_and_parse_format(). */
> +int snd_oxfw_stream_parse_format(const u8 *format,
> + struct snd_oxfw_stream_formation *formation)
> +{
> + unsigned int i, e, channels, type;
> +
> + memset(formation, 0, sizeof(struct snd_oxfw_stream_formation));
> +
> + for (i = 0; i < ARRAY_SIZE(avc_stream_rate_table); i++) {
> + if (format[2] == avc_stream_rate_table[i])
> + break;
> + }
> + if (i == ARRAY_SIZE(avc_stream_rate_table))
> + return -ENXIO;
> +
> + formation->rate = oxfw_rate_table[i];
> +
> + for (e = 0; e < format[4]; e++) {
> + channels = format[5 + e * 2];
> + type = format[6 + e * 2];
> +
> + if (type == 0x00 || type == 0x06)
> + formation->pcm += channels;
> + else if (type == 0x0d)
> + formation->midi = channels;
> + }
> +
> + return 0;
> +}
[Severity: Low]
Does snd_oxfw_stream_parse_format() need to duplicate the memset(),
avc_stream_rate_table lookup, and format[4] entry loop from
check_and_parse_format()? Keeping two copies of the parser in the same
file risks divergence between live and cached format parsing and adds
churn to a stable-tagged fix.
Instead, check_and_parse_format() could just validate format[0..1] and
len, then delegate directly to the existing
snd_oxfw_stream_parse_format().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-firewire-avc-bounds-v4-0-d90e91e0088e@gmail.com?part=3
prev parent reply other threads:[~2026-12-05 17:29 UTC|newest]
Thread overview: 6+ 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 ` [PATCH v4 1/3] ALSA: bebob: bound the channel position walk " Maoyi Xie via B4 Relay
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:23 ` sashiko-bot
2026-12-05 17:14 ` [PATCH v4 3/3] ALSA: oxfw: " Maoyi Xie via B4 Relay
2026-12-05 17:29 ` sashiko-bot [this message]
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-251767@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