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 --- I used an LLM to help write the harness and this patch. v2: No change. 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