From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Clemens Ladisch <clemens@ladisch.de>,
Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 2/3] ALSA: bebob: bound the stream format entries to the response length
Date: Wed, 25 Nov 2026 20:12:37 +0800 [thread overview]
Message-ID: <20261125121238.1602172-3-maoyixie.tju@gmail.com> (raw)
In-Reply-To: <20261125121238.1602172-1-maoyixie.tju@gmail.com>
parse_stream_formation() takes the number of two-byte entries of a
stream format from buf[4]. It ignores its len argument. A count of 62
or more can read past the 128-byte buffer. A smaller count can still
read bytes that are not part of the response.
Return -EIO when the entries do not fit into the response.
Found with a CodeQL-based static analysis tool. Reproduced in a
userspace harness under AddressSanitizer. Not tested on hardware.
Fixes: eb7b3a056cd8 ("ALSA: bebob: Add commands and connections/streams management")
Cc: stable@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness and this patch.
sound/firewire/bebob/bebob_stream.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sound/firewire/bebob/bebob_stream.c b/sound/firewire/bebob/bebob_stream.c
index 5850357cb3da..8eceafc70a44 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;
+
/* Avoid double count by different entries for the same rate. */
memset(&formation[i], 0, sizeof(struct snd_bebob_stream_formation));
--
2.34.1
next prev parent reply other threads:[~2026-11-25 12:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 12:12 [PATCH 0/3] ALSA: bebob/oxfw: bound AV/C response walks to the response length Maoyi Xie
2026-11-25 12:12 ` [PATCH 1/3] ALSA: bebob: bound the channel position walk " Maoyi Xie
2026-11-25 12:12 ` Maoyi Xie [this message]
2026-11-25 12:12 ` [PATCH 3/3] ALSA: oxfw: bound the stream format entries " Maoyi Xie
2026-11-28 7:09 ` Takashi Sakamoto
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=20261125121238.1602172-3-maoyixie.tju@gmail.com \
--to=maoyixie.tju@gmail.com \
--cc=clemens@ladisch.de \
--cc=linux-sound@vger.kernel.org \
--cc=o-takashi@sakamocchi.jp \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.com \
/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