Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Alexandre Becholey <alex@becholey.ch>
Cc: Daniel Mack <zonque@gmail.com>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Karsten Wiese <fzu@wemgehoertderstaat.de>,
	stable@vger.kernel.org, Daniel Mack <daniel@caiaq.org>,
	Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@suse.cz>,
	linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: caiaq: stop the iso packet parsers before a partial block
Date: Mon, 23 Nov 2026 09:57:40 +0100	[thread overview]
Message-ID: <875wxnexh7.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261119131632.650637-1-alex@becholey.ch>

On Thu, 19 Nov 2026 14:16:55 +0100,
Alexandre Becholey wrote:
> 
> The iso packet parsers in audio.c walk a packet in blocks of one sample
> per stream, but only compare the start of each block with the packet
> length. The block size follows from the channel counts the device
> reports, so it need not divide the packet length, and the last block of
> a packet runs past its end. A device reporting e.g. 62 channels can make
> the driver read and write up to 232 bytes past the capture and playback
> URB buffers in URB completion context.
> 
> Make each parser round the packet length down to a multiple of its own
> block size, which depends only on n_streams and not on
> spec.data_alignment (the device can change that at any time), and zero
> the unused tail of a playback packet.
> 
> The bug was found, and the reproducer and this fix were written, by AI
> agents (Claude Mythos and Claude Opus models). The analysis and the
> patch were reviewed by a human.
> 
> Fixes: 523f1dce3743 ("[ALSA] Add Native Instrument usb audio device support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexandre Becholey <alex@becholey.ch>
> ---
> An emulated caiaq device on QEMU xHCI reporting 62 channels and sending
> 512-byte iso packets triggers KASAN slab-out-of-bounds in
> read_completed() on v7.3.1 and master 9d66f26fefac, as do 3- and
> 12-stream variants in modes 0, 2 and 3, also with the device switching
> data_alignment mid-stream. With the fix: no report in 85 boots (20 on
> master); a well-behaved 4-stream device streams as before in modes 0, 2
> and 3. Not tested on real hardware. Reproducer available on request.

OK, I applied now to for-next branch, and let's hope this works on the
actual device, too.


thanks,

Takashi

      reply	other threads:[~2026-11-23  8:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:16 [PATCH] ALSA: caiaq: stop the iso packet parsers before a partial block Alexandre Becholey
2026-11-23  8:57 ` Takashi Iwai [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=875wxnexh7.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alex@becholey.ch \
    --cc=daniel@caiaq.org \
    --cc=fzu@wemgehoertderstaat.de \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=perex@suse.cz \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.com \
    --cc=zonque@gmail.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