]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ALSA: aloop: Fix peer runtime UAF during format-change stop
authorCássio Gabriel <cassiogabrielcontato@gmail.com>
Fri, 24 Apr 2026 12:48:41 +0000 (09:48 -0300)
committerTakashi Iwai <tiwai@suse.de>
Mon, 27 Apr 2026 11:50:37 +0000 (13:50 +0200)
commite5c33cdc6f402eab8abd36ecf436b22c9d3a8aff
tree0a9a3f37f808663f67c7ee5b99bf7c29a44e4bd3
parent901ac0ff15edf9503162e2cf6579bd11a30f1ed4
ALSA: aloop: Fix peer runtime UAF during format-change stop

loopback_check_format() may stop the capture side when playback starts
with parameters that no longer match a running capture stream. Commit
826af7fa62e3 ("ALSA: aloop: Fix racy access at PCM trigger") moved
the peer lookup under cable->lock, but the actual snd_pcm_stop() still
runs after dropping that lock.

A concurrent close can clear the capture entry from cable->streams[] and
detach or free its runtime while the playback trigger path still holds a
stale peer substream pointer.

Keep a per-cable count of in-flight peer stops before dropping
cable->lock, and make free_cable() wait for those stops before
detaching the runtime. This preserves the existing behavior while
making the peer runtime lifetime explicit.

Reported-by: syzbot+8fa95c41eafbc9d2ff6f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8fa95c41eafbc9d2ff6f
Fixes: 597603d615d2 ("ALSA: introduce the snd-aloop module for the PCM loopback")
Cc: stable@vger.kernel.org
Suggested-by: Takashi Iwai <tiwai@suse.com>
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260424-alsa-aloop-peer-stop-uaf-v2-1-94e68101db8a@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/drivers/aloop.c