From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C62F82BE630 for ; Wed, 13 May 2026 14:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778681429; cv=none; b=PRCCQel4p0UcTKpWUa9+xSFDJcZMbs90DD3SxovLNdyL0l3uuyN+bUcQMs1T1EK3NVD7AjDJ5Mphghnn17atxVmAr5ciyljCmjbauzsRZ5GN70kIU5WoqZHHApCcFEj3mDygroKotAJ8veXqWrR+Dw3ei1VfG7uFr4nfROrpS18= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778681429; c=relaxed/simple; bh=A9qL67fRAZqQZ5fN5HLDD9iRYpULquQ37/ahXEYuxts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A7aLe8wRwsJpdJB6dcWHrJdmA0GBYTMPoIWGS+d77lW6Hg58lG0WUQbJHn75/pHmncNJztRQ+yj3K+HShnWWxEszScQ9C1Qz7xu7a+nt0QlpztpqGI/SuLGFtMLZ+2mW9a3zIdoIg1CSsIhU1Vs0fQ5HjRMKAMJqljuDFrW7z9Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f22c9qcG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f22c9qcG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26906C19425; Wed, 13 May 2026 14:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778681429; bh=A9qL67fRAZqQZ5fN5HLDD9iRYpULquQ37/ahXEYuxts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f22c9qcGr6/pGDaUEkpys4drOWdnWf/jUjkJe7dGKabgUcgq0JBHS2OHR0EWJdh7Q uQXL6mIZJ9agH19jlKoDP7rGs8Fd4StJRF1sir0rgF8lC/QGIzfxjAs8phlIo/O20n S1eAp0FtOlAyuls1OUdStQSRTRgmW8bntvHNcAdJv2BJqubRyHWFgR6R03kuMANBUh d3PK8Ob2Jds3kqh313TOTev8JuPRK8bNZ0cWMZMWS4WCOUd0pMOrKVRXLSWWAwx9sz hs6g51hTfVmDrm0lh4RxfUI6Bk6+uJQE+rkuuw1848XhGIJZoPtvMp4QB8nv3jKQB0 aJWEdf1pleIcA== From: Sasha Levin To: stable@vger.kernel.org Cc: =?UTF-8?q?C=C3=A1ssio=20Gabriel?= , Takashi Iwai , Sasha Levin Subject: [PATCH 6.6.y 3/3] ALSA: core: Serialize deferred fasync state checks Date: Wed, 13 May 2026 10:10:25 -0400 Message-ID: <20260513141025.3748103-3-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260513141025.3748103-1-sashal@kernel.org> References: <2026051250-tattered-mulled-92f0@gregkh> <20260513141025.3748103-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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