From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 987D3C25B06 for ; Sun, 14 Aug 2022 16:25:06 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C1604AE9; Sun, 14 Aug 2022 18:24:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C1604AE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1660494304; bh=BWjidRQ+edWUR4aH7drez7StIMEyzcJyA/RtL4QAKXA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sBvZIvj8FUqp9ZKKGwf4T9jhheM9IzG3Glwh5MWXoAg6370EewO455Co4OzjG5c0T XYBT9CVi/JsUs4wWTYRppjohFdExSVHm+tUzWOchGNXTcYgMmmaJNV6wTcAOkqihJ0 dY/vg0bApYdlr8lZyrZbblXuLsK4Y8+xTjVaMeco= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A7E52F8055C; Sun, 14 Aug 2022 18:23:06 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0A844F80567; Sun, 14 Aug 2022 18:23:05 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C5D6BF800B8 for ; Sun, 14 Aug 2022 18:22:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C5D6BF800B8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hFoySHI7" Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 41BF160F40; Sun, 14 Aug 2022 16:22:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09808C433C1; Sun, 14 Aug 2022 16:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660494176; bh=BWjidRQ+edWUR4aH7drez7StIMEyzcJyA/RtL4QAKXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hFoySHI71rG1Kl1I3iPGyDYiE6pk/RKnMAqcO8Z0gzzCT3A3PGXl3z1hrFpcw3rsK pmL0fdAqfOwCjbjOh/2jFvpInJLIzWq2pJE3CTzewqvd1jCc5quZtMtTwCy/8P+HOS N0NtWe3zQavJ+tmVSsBVt115KlV3gLAQt1LesSk839AF7QkSC2dkFyyzcykAvLeNXG u12lQWwMA3wxEDaGwLgu+a2/uwY+wNOsGQs7olD00IOzv8LC+SQ5j0qH02c5Wdwr9u EmQHRNJXPkSf74p9TwT2C6tkC13KSvAgDsrT40qCJMmfd/lv61j+n8lYUEwj/vdUwW 8CTZkxzAfx/bw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.19 38/48] ALSA: pcm: Use deferred fasync helper Date: Sun, 14 Aug 2022 12:19:31 -0400 Message-Id: <20220814161943.2394452-38-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814161943.2394452-1-sashal@kernel.org> References: <20220814161943.2394452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Cc: Sasha Levin , pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, zsm@chromium.org, kai.vehmanen@linux.intel.com, Takashi Iwai , tiwai@suse.com, broonie@kernel.org, syzbot+669c9abf11a6a011dd09@syzkaller.appspotmail.com, ranjani.sridharan@linux.intel.com, syzbot+8285e973a41b5aa68902@syzkaller.appspotmail.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Takashi Iwai [ Upstream commit 96b097091c66df4f6fbf5cbff21df6cc02a2f055 ] For avoiding the potential deadlock via kill_fasync() call, use the new fasync helpers to defer the invocation from timer API. Note that it's merely a workaround. Reported-by: syzbot+8285e973a41b5aa68902@syzkaller.appspotmail.com Reported-by: syzbot+669c9abf11a6a011dd09@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20220728125945.29533-4-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- include/sound/pcm.h | 2 +- sound/core/pcm.c | 1 + sound/core/pcm_lib.c | 2 +- sound/core/pcm_native.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 6b99310b5b88..6987110843f0 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -399,7 +399,7 @@ struct snd_pcm_runtime { snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */ wait_queue_head_t sleep; /* poll sleep */ wait_queue_head_t tsleep; /* transfer sleep */ - struct fasync_struct *fasync; + struct snd_fasync *fasync; bool stop_operating; /* sync_stop will be called */ struct mutex buffer_mutex; /* protect for buffer changes */ atomic_t buffer_accessing; /* >0: in r/w operation, <0: blocked */ diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 977d54320a5c..c917ac84a7e5 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1005,6 +1005,7 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream) substream->runtime = NULL; } mutex_destroy(&runtime->buffer_mutex); + snd_fasync_free(runtime->fasync); kfree(runtime); put_pid(substream->pid); substream->pid = NULL; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 1fc7c50ffa62..40751e5aff09 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1822,7 +1822,7 @@ void snd_pcm_period_elapsed_under_stream_lock(struct snd_pcm_substream *substrea snd_timer_interrupt(substream->timer, 1); #endif _end: - kill_fasync(&runtime->fasync, SIGIO, POLL_IN); + snd_kill_fasync(runtime->fasync, SIGIO, POLL_IN); } EXPORT_SYMBOL(snd_pcm_period_elapsed_under_stream_lock); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 4adaee62ef33..16fcf57c6f03 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3945,7 +3945,7 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) runtime = substream->runtime; if (runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED) return -EBADFD; - return fasync_helper(fd, file, on, &runtime->fasync); + return snd_fasync_helper(fd, file, on, &runtime->fasync); } /* -- 2.35.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC3C3C28B2C for ; Sun, 14 Aug 2022 16:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241100AbiHNQ0S (ORCPT ); Sun, 14 Aug 2022 12:26:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242189AbiHNQZI (ORCPT ); Sun, 14 Aug 2022 12:25:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A2118E02; Sun, 14 Aug 2022 09:22:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4234960F98; Sun, 14 Aug 2022 16:22:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09808C433C1; Sun, 14 Aug 2022 16:22:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660494176; bh=BWjidRQ+edWUR4aH7drez7StIMEyzcJyA/RtL4QAKXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hFoySHI71rG1Kl1I3iPGyDYiE6pk/RKnMAqcO8Z0gzzCT3A3PGXl3z1hrFpcw3rsK pmL0fdAqfOwCjbjOh/2jFvpInJLIzWq2pJE3CTzewqvd1jCc5quZtMtTwCy/8P+HOS N0NtWe3zQavJ+tmVSsBVt115KlV3gLAQt1LesSk839AF7QkSC2dkFyyzcykAvLeNXG u12lQWwMA3wxEDaGwLgu+a2/uwY+wNOsGQs7olD00IOzv8LC+SQ5j0qH02c5Wdwr9u EmQHRNJXPkSf74p9TwT2C6tkC13KSvAgDsrT40qCJMmfd/lv61j+n8lYUEwj/vdUwW 8CTZkxzAfx/bw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Takashi Iwai , syzbot+8285e973a41b5aa68902@syzkaller.appspotmail.com, syzbot+669c9abf11a6a011dd09@syzkaller.appspotmail.com, Sasha Levin , perex@perex.cz, tiwai@suse.com, kai.vehmanen@linux.intel.com, broonie@kernel.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, zsm@chromium.org, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.19 38/48] ALSA: pcm: Use deferred fasync helper Date: Sun, 14 Aug 2022 12:19:31 -0400 Message-Id: <20220814161943.2394452-38-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814161943.2394452-1-sashal@kernel.org> References: <20220814161943.2394452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai [ Upstream commit 96b097091c66df4f6fbf5cbff21df6cc02a2f055 ] For avoiding the potential deadlock via kill_fasync() call, use the new fasync helpers to defer the invocation from timer API. Note that it's merely a workaround. Reported-by: syzbot+8285e973a41b5aa68902@syzkaller.appspotmail.com Reported-by: syzbot+669c9abf11a6a011dd09@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20220728125945.29533-4-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- include/sound/pcm.h | 2 +- sound/core/pcm.c | 1 + sound/core/pcm_lib.c | 2 +- sound/core/pcm_native.c | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 6b99310b5b88..6987110843f0 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -399,7 +399,7 @@ struct snd_pcm_runtime { snd_pcm_uframes_t twake; /* do transfer (!poll) wakeup if non-zero */ wait_queue_head_t sleep; /* poll sleep */ wait_queue_head_t tsleep; /* transfer sleep */ - struct fasync_struct *fasync; + struct snd_fasync *fasync; bool stop_operating; /* sync_stop will be called */ struct mutex buffer_mutex; /* protect for buffer changes */ atomic_t buffer_accessing; /* >0: in r/w operation, <0: blocked */ diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 977d54320a5c..c917ac84a7e5 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -1005,6 +1005,7 @@ void snd_pcm_detach_substream(struct snd_pcm_substream *substream) substream->runtime = NULL; } mutex_destroy(&runtime->buffer_mutex); + snd_fasync_free(runtime->fasync); kfree(runtime); put_pid(substream->pid); substream->pid = NULL; diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 1fc7c50ffa62..40751e5aff09 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1822,7 +1822,7 @@ void snd_pcm_period_elapsed_under_stream_lock(struct snd_pcm_substream *substrea snd_timer_interrupt(substream->timer, 1); #endif _end: - kill_fasync(&runtime->fasync, SIGIO, POLL_IN); + snd_kill_fasync(runtime->fasync, SIGIO, POLL_IN); } EXPORT_SYMBOL(snd_pcm_period_elapsed_under_stream_lock); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 4adaee62ef33..16fcf57c6f03 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -3945,7 +3945,7 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) runtime = substream->runtime; if (runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED) return -EBADFD; - return fasync_helper(fd, file, on, &runtime->fasync); + return snd_fasync_helper(fd, file, on, &runtime->fasync); } /* -- 2.35.1