From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: "Cássio Gabriel" <cassiogabrielcontato@gmail.com>,
"Takashi Iwai" <tiwai@suse.de>, "Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.10.y] ALSA: core: Serialize deferred fasync state checks
Date: Wed, 13 May 2026 12:46:26 -0400 [thread overview]
Message-ID: <20260513164626.3816356-1-sashal@kernel.org> (raw)
In-Reply-To: <2026051257-shopping-sitcom-fcf1@gregkh>
From: Cássio Gabriel <cassiogabrielcontato@gmail.com>
[ Upstream commit 5337213381df578058e2e41da93cbd0e4639935f ]
snd_fasync_helper() updates fasync->on under snd_fasync_lock, and
snd_fasync_work_fn() now also evaluates fasync->on under the same
lock. snd_kill_fasync() still tests the flag before taking the lock,
leaving an unsynchronized read against FASYNC enable/disable updates.
Move the enabled-state check into the locked section.
Also clear fasync->on under snd_fasync_lock in snd_fasync_free()
before unlinking the pending entry. Together with the locked sender-side
check, this publishes teardown before flushing the deferred work and
prevents a racing sender from requeueing the entry after free has
started.
Fixes: ef34a0ae7a26 ("ALSA: core: Add async signal helpers")
Fixes: 8146cd333d23 ("ALSA: core: Fix potential data race at fasync handling")
Cc: stable@vger.kernel.org
Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com>
Link: https://patch.msgid.link/20260506-alsa-core-fasync-on-lock-v1-1-ea48c77d6ca4@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
[ converted upstream guard()/scoped_guard() to explicit spin_lock_irqsave/spin_lock_irq and dropped the list_del_init() from a missing prerequisite ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/core/misc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/core/misc.c b/sound/core/misc.c
index c3f3d94b51970..51f175b2f9c8e 100644
--- a/sound/core/misc.c
+++ b/sound/core/misc.c
@@ -219,9 +219,13 @@ void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll)
{
unsigned long flags;
- if (!fasync || !fasync->on)
+ if (!fasync)
return;
spin_lock_irqsave(&snd_fasync_lock, flags);
+ if (!fasync->on) {
+ spin_unlock_irqrestore(&snd_fasync_lock, flags);
+ return;
+ }
fasync->signal = signal;
fasync->poll = poll;
list_move(&fasync->list, &snd_fasync_list);
@@ -234,7 +238,9 @@ void snd_fasync_free(struct snd_fasync *fasync)
{
if (!fasync)
return;
+ spin_lock_irq(&snd_fasync_lock);
fasync->on = 0;
+ spin_unlock_irq(&snd_fasync_lock);
flush_work(&snd_fasync_work);
kfree(fasync);
}
--
2.53.0
prev parent reply other threads:[~2026-05-13 16:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-12 12:31 FAILED: patch "[PATCH] ALSA: core: Serialize deferred fasync state checks" failed to apply to 5.10-stable tree gregkh
2026-05-13 16:46 ` Sasha Levin [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=20260513164626.3816356-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=cassiogabrielcontato@gmail.com \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
/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