From: Takashi Iwai <tiwai@suse.de>
To: Ji'an Zhou <eilaimemedsnaimel@gmail.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, tiwai@suse.de
Subject: Re: [PATCH] ALSA: PCM: Fix wait queue list corruption in snd_pcm_drain() on linked streams
Date: Thu, 04 Jun 2026 17:25:10 +0200 [thread overview]
Message-ID: <87v7byuy3t.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260604142559.3840881-1-eilaimemedsnaimel@gmail.com>
On Thu, 04 Jun 2026 16:25:59 +0200,
Ji'an Zhou wrote:
>
> snd_pcm_drain() uses init_waitqueue_entry which does not clear
> entry.prev/next, and add_wait_queue with a conditional
> remove_wait_queue that is skipped when to_check is no longer
> in the group after concurrent UNLINK. The orphaned wait entry
> remains on the unlinked substream sleep queue. On the next
> drain iteration, add_wait_queue adds the entry to a new queue
> while still linked on the old one, corrupting both lists. A
> subsequent wake_up dereferences NULL at the func pointer
> (mapped from the spinlock at offset 0 of the misinterpreted
> wait_queue_head_t), causing a kernel panic.
>
> Replace init_waitqueue_entry/add_wait_queue/conditional
> remove_wait_queue with init_wait_entry/prepare_to_wait/
> finish_wait. init_wait_entry clears prev/next via
> INIT_LIST_HEAD on each iteration and sets
> autoremove_wake_function which auto-removes the entry on
> wake-up. finish_wait safely handles both the already-removed
> and still-queued cases.
>
> Fixes: 9b1dbd69ba6f ("ALSA: pcm: fix use-after-free on linked stream runtime in snd_pcm_drain")
> Signed-off-by: Ji'an Zhou <eilaimemedsnaimel@gmail.com>
Applied now. Thanks.
Takashi
prev parent reply other threads:[~2026-06-04 15:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 14:25 [PATCH] ALSA: PCM: Fix wait queue list corruption in snd_pcm_drain() on linked streams Ji'an Zhou
2026-06-04 15:25 ` 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=87v7byuy3t.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=eilaimemedsnaimel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
/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