From: Takashi Iwai <tiwai@suse.de>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: "Jaroslav Kysela" <perex@perex.cz>,
"Takashi Iwai" <tiwai@suse.com>,
"Christophe Leroy" <chleroy@kernel.org>,
"Mehul Rao" <mehulrao@gmail.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Cássio Gabriel" <cassiogabrielcontato@gmail.com>,
"Cen Zhang" <zzzccc427@gmail.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: pcm: keep linked runtime alive while draining
Date: Fri, 05 Jun 2026 08:24:06 +0200 [thread overview]
Message-ID: <87mrx9v721.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260605051637.1442529-1-lgs201920130244@gmail.com>
On Fri, 05 Jun 2026 07:16:37 +0200,
Guangshuo Li wrote:
>
> snd_pcm_drain() may select a runtime from a linked playback stream and
> queue a stack wait entry on its embedded sleep waitqueue. The function
> then drops the stream lock and sleeps before removing the wait entry.
>
> commit 9b1dbd69ba6f ("ALSA: pcm: fix use-after-free on linked stream
> runtime in snd_pcm_drain()") cached scalar fields from the linked
> runtime before dropping the stream lock, because a concurrent close can
> unlink the stream and free its runtime. The same lifetime issue remains
> for runtime->sleep. If the linked runtime is detached while the wait
> entry is queued, remove_wait_queue() can later operate on a freed or
> reused waitqueue, or the stack wait entry can remain linked to freed
> memory.
>
> Take snd_pcm_link_rwsem for read while the wait entry is queued on the
> linked runtime. Acquire it before re-taking the stream lock, matching the
> link/unlink lock order, and drop it only after the wait entry has been
> removed.
>
> Fixes: 21cb2a2ec581 ("[ALSA] Fix races between PCM drain and other ops")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
This should have been already fixed by the commit 88fe2e365872
ALSA: PCM: Fix wait queue list corruption in snd_pcm_drain() on
linked streams
in for-linus branch of sound.git tree.
Please check whether the issue still occurs.
thanks,
Takashi
next prev parent reply other threads:[~2026-06-05 6:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 5:16 Guangshuo Li
2026-06-05 6:24 ` Takashi Iwai [this message]
2026-06-09 15:23 ` Guangshuo Li
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=87mrx9v721.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=bigeasy@linutronix.de \
--cc=cassiogabrielcontato@gmail.com \
--cc=chleroy@kernel.org \
--cc=lgs201920130244@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=mehulrao@gmail.com \
--cc=nathan@kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=zzzccc427@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
all inboxes | Powered by JetHome®