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 591703DC87A; Tue, 16 Jun 2026 19:00:08 +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=1781636409; cv=none; b=LfWhd1phy1ukHL3/qPbmjZo1yd4r0lptmuTTtG4o5NCp1jCQHDxbczzW6Ici9jHr1DBooHxcPbYKI5ipCFALhDJpxLVUG8vjt+VGf7elUKSakJvJufvSMh39d5kscMs9DY2N8rqq9EvjRy42PyKMavsENC5tak5q81Twm6Cn/5Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781636409; c=relaxed/simple; bh=Og1W0G8K2lDbCVrxhLEEszlsCDMSbDQDq34mogvlt+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BPbjDTTwIyEhpOv+kGm81ttczDpy3IQMUVazNObCVl8FZzwRcs9W7SCrTiXR0v3DzCDhg6p4H4Qxum9/FAj3Nn+kvw9TQfv4y6yB/zvFA0KiU03ZjP+tktQEJmQ6VARP/PYmk4F7pmKoctFED2S3r/KLrnushooAJw6mMssvYhw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=znO7Vv1B; 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="znO7Vv1B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AF551F000E9; Tue, 16 Jun 2026 19:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781636408; bh=k35Bh/G1YCGQ1+2cLksSA7HMNlTf9KtSLsifryMzU8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=znO7Vv1BV/KEDSKEYIUPz2EUr9m3Jbx24t3M3ECWfEgzWCL/HuWVtCV0hptUdkjNS RsVeSd+CgaAX5+nBUDdhWnNFae1T+LLYHGpNP3KzvvDHr3RwYGIlAkIcT6KxUPOUgi Iu02ef48Ad7B3q/HC/WIZK2RM6ZnLywLavHbZeDA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jake Lamberson , Takashi Iwai , Sasha Levin Subject: [PATCH 5.10 233/342] ALSA: core: Fix potential data race at fasync handling Date: Tue, 16 Jun 2026 20:28:49 +0530 Message-ID: <20260616145059.055164540@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145048.348037099@linuxfoundation.org> References: <20260616145048.348037099@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-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai [ Upstream commit 8146cd333d235ed32d48bb803fdf743472d7c783 ] In snd_fasync_work_fn(), which is the offload work for traversing and processing the pending fasync list, the call of kill_fasync() is done outside the snd_fasync_lock for avoiding deadlocks. The problem is that its the references of fasync->on, fasync->signal and fasync->poll are done there also outside the lock. Since these may be modified by snd_kill_fasync() call concurrently from other process, inconsistent values might be passed to kill_fasync(). Although there shouldn't be critical UAF, it's still better to be addressed. This patch moves the kill_fasync() argument evaluations inside the snd_fasync_lock for avoiding the data races above. The handling in fasync->on flag is optimized in the loop to skip directly. Also, for more clarity, snd_fasync_free() takes the lock and unlink the pending entry more directly instead of clearing fasync->on flag. Reported-by: Jake Lamberson Fixes: ef34a0ae7a26 ("ALSA: core: Add async signal helpers") Cc: Link: https://patch.msgid.link/20260420061721.3253644-1-tiwai@suse.de Signed-off-by: Takashi Iwai [ replaced scoped_guard(spinlock_irq, &snd_fasync_lock) with explicit spin_lock_irq()/spin_unlock_irq() ] Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/core/misc.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -171,14 +171,18 @@ static LIST_HEAD(snd_fasync_list); static void snd_fasync_work_fn(struct work_struct *work) { struct snd_fasync *fasync; + int signal, poll; spin_lock_irq(&snd_fasync_lock); while (!list_empty(&snd_fasync_list)) { fasync = list_first_entry(&snd_fasync_list, struct snd_fasync, list); list_del_init(&fasync->list); + if (!fasync->on) + continue; + signal = fasync->signal; + poll = fasync->poll; spin_unlock_irq(&snd_fasync_lock); - if (fasync->on) - kill_fasync(&fasync->fasync, fasync->signal, fasync->poll); + kill_fasync(&fasync->fasync, signal, poll); spin_lock_irq(&snd_fasync_lock); } spin_unlock_irq(&snd_fasync_lock); @@ -234,7 +238,11 @@ void snd_fasync_free(struct snd_fasync * { if (!fasync) return; - fasync->on = 0; + + spin_lock_irq(&snd_fasync_lock); + list_del_init(&fasync->list); + spin_unlock_irq(&snd_fasync_lock); + flush_work(&snd_fasync_work); kfree(fasync); }