From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D540333B6C4; Sat, 30 May 2026 17:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162123; cv=none; b=AgeIsNgwOQ8U0NIi3MLc8VnCIhWJJMup2D/cIY93r7dogfx9e37tQTq6pyXIcF88VRKXTNoFuIzVG92oT4PLQxif7CoFpNgY6r0p89h3L1LRSM4pRgR/RmVw9yNWCpzZ6qkmdMf6GTIJqA6MA+2iX50Z0Mf64nkHFNMkC0t4CeA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162123; c=relaxed/simple; bh=Wclg6Ll0XbTpiJYRhmCo+l2AcglhI62D555SsPTrUP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s2ASGXsRMk2z8kj5JQoi5w0jMnEQD2YVkY0ODTRvtLTdrYiUPEcJQCk7GTZxJoMNJa6J+xhBCZeWqHfTDG2XFdJaLX+jvGraH2rDEml7MXZECVkR5QUV5EHuPTcjjdY3mcRBrJAZ8mOgwMOCaNKpVmN+NwkIM0HWjWXKN0keBWE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sJBoGGtB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="sJBoGGtB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24C9A1F00893; Sat, 30 May 2026 17:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780162122; bh=YKp0JPIzBijvdLxuaUt5j+PMiGUawQhobRox2kLMTwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sJBoGGtBuE2mAsgZ6/JIBk0kDMbsTloRUQtD6OKBQ3WHjN/TjD1vGOydB7YByzNFv YU+P43F3Z15TtRDnxpCfkRSeYFQ5ommulk6BZSPxf9oevQF7FC8zquOQ62xi+Jnrdb b8XRBbd601GKu9srYelHNRh6Q3Eob8d9eh14uyso= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?C=C3=A1ssio=20Gabriel?= , Takashi Iwai , Sasha Levin Subject: [PATCH 6.1 798/969] ALSA: core: Serialize deferred fasync state checks Date: Sat, 30 May 2026 18:05:22 +0200 Message-ID: <20260530160322.659134561@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cássio Gabriel [ 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 Link: https://patch.msgid.link/20260506-alsa-core-fasync-on-lock-v1-1-ea48c77d6ca4@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/misc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/core/misc.c b/sound/core/misc.c index 918d59a541c82..fd891a3ceb963 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -219,9 +219,11 @@ EXPORT_SYMBOL_GPL(snd_fasync_helper); void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll) { - if (!fasync || !fasync->on) + if (!fasync) return; guard(spinlock_irqsave)(&snd_fasync_lock); + if (!fasync->on) + return; fasync->signal = signal; fasync->poll = poll; list_move(&fasync->list, &snd_fasync_list); @@ -234,8 +236,10 @@ void snd_fasync_free(struct snd_fasync *fasync) if (!fasync) return; - scoped_guard(spinlock_irq, &snd_fasync_lock) + scoped_guard(spinlock_irq, &snd_fasync_lock) { + fasync->on = 0; list_del_init(&fasync->list); + } flush_work(&snd_fasync_work); kfree(fasync); -- 2.53.0