Linux Sound subsystem development
 help / color / mirror / Atom feed
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 v3 4/4] ALSA: oxfw: bound the current format entries to the response length
Date: Wed,  2 Dec 2026 15:04:52 +0800	[thread overview]
Message-ID: <20261202070452.732525-5-maoyixie.tju@gmail.com> (raw)
In-Reply-To: <20261202070452.732525-1-maoyixie.tju@gmail.com>

snd_oxfw_stream_get_current_formation() reads the current format from
the unit into a new 512-byte buffer and parses it. A count of 254 or
255 in format[4] can read past that buffer. This response is not
cached, so the check at discovery does not cover it.

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: 3c96101f1900 ("ALSA: oxfw: Add proc interface for debugging purpose")
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.

v3: New.

 sound/firewire/oxfw/oxfw-stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/firewire/oxfw/oxfw-stream.c b/sound/firewire/oxfw/oxfw-stream.c
index 858f4b8a4656..40f0267cd1d6 100644
--- a/sound/firewire/oxfw/oxfw-stream.c
+++ b/sound/firewire/oxfw/oxfw-stream.c
@@ -501,7 +501,7 @@ int snd_oxfw_stream_get_current_formation(struct snd_oxfw *oxfw,
 
 		err = avc_stream_get_format_single(oxfw->unit, dir, 0, format, &len);
 		if (err >= 0) {
-			if (len < 3)
+			if (len < 5 || len < 5 + format[4] * 2)
 				err = -EIO;
 			else
 				err = snd_oxfw_stream_parse_format(format, formation);
-- 
2.34.1


      parent reply	other threads:[~2026-12-02  7:05 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
2026-12-02  7:04 ` [PATCH v3 3/4] ALSA: oxfw: " Maoyi Xie
2026-12-02  7:04 ` Maoyi Xie [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=20261202070452.732525-5-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