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 8411FEB64D9 for ; Tue, 27 Jun 2023 10:02:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0888383B; Tue, 27 Jun 2023 12:02:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0888383B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1687860171; bh=OSIe4vWDMd3C91gcOtyZTaw9iwGHgFa14MtfjfpDvJc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kmj5KXVYJThzJapRrbX+ggNR8Gvf2Cmj/1zUDjaag85XlfsNOcn7vFLTkqWPrgzig mWZs+GBJejB+n7xU55G3QAXbcVw492cqNdZPWmyi8ep06+Z3v23d8ub5jc+PjwbYfZ Y14qbihGwWosCd9U0SXpfEN1ePOsFHMoyQYjD+7E= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 97A55F80544; Tue, 27 Jun 2023 12:01:36 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 1DB4CF80212; Tue, 27 Jun 2023 12:01:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3F1E8F8027B; Tue, 27 Jun 2023 12:01:33 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C2A56F80093 for ; Tue, 27 Jun 2023 12:01:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C2A56F80093 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=saM1f90g; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1Wypp5iZ Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 61DF81F459; Tue, 27 Jun 2023 10:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687860090; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K4T27Nhu/TEwjb/aRpRTTZPClPb2AOGo8itCCHtR91s=; b=saM1f90gMGB0ViGO8FnkiAEU5VDIl7brg9Px7UgHq1Lqz3ERnawr4BoWxClD3DDJb1+9jJ BXXp1HiV9rmA68HgjekBoz3JeMDlVQjMGNCvWl6N2b36iQkU+A/KY/28GZ7DfT/K6SjSAT 3TAlpqk6ggS0eEuiCKkA4P3w4othOWs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687860090; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K4T27Nhu/TEwjb/aRpRTTZPClPb2AOGo8itCCHtR91s=; b=1Wypp5iZW9kgslLY21klRlfw02n+jYZKQiS84apSErbaKZBLQ3XHTt77kRi1LPgwVWIXjP YmePinuAtIBEbTBg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2FD1113462; Tue, 27 Jun 2023 10:01:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MrbQCnqzmmQrcAAAMHmgww (envelope-from ); Tue, 27 Jun 2023 10:01:30 +0000 Date: Tue, 27 Jun 2023 12:01:29 +0200 Message-ID: <87jzvpfcli.wl-tiwai@suse.de> From: Takashi Iwai To: Chengfeng Ye Cc: perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ALSA: sb: fix potential deadlock on &chip->mixer_lock In-Reply-To: <20230627095616.5333-1-dg573847474@gmail.com> References: <20230627095616.5333-1-dg573847474@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Message-ID-Hash: EHXLN3Y7AZRXBML44GNQEZCQPO6AO3Q5 X-Message-ID-Hash: EHXLN3Y7AZRXBML44GNQEZCQPO6AO3Q5 X-MailFrom: tiwai@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Tue, 27 Jun 2023 11:56:16 +0200, Chengfeng Ye wrote: > > As &chip->mixer_lock is also acquired by the irq snd_sb8dsp_interrupt() > which executes under hard-irq context, code executing under process > context should disable irq before acquiring the lock, otherwise > deadlock could happen if the process context hold the lock then > preempt by the interruption. > > As the ALSA Driver document described, PCM prepare callbacks are not > executed with irq disabled by default, thus the acquiring of > &chip->mixer_lock should be irq disabled. > > Possible deadlock scenario: > snd_sb8_playback_prepare > -> spin_lock(&chip->mixer_lock); > > -> snd_sb8dsp_interrupt() > -> snd_sb8_capture_trigger() > -> spin_lock(&chip->mixer_lock); (deadlock here) > > This flaw was found using an experimental static analysis tool we are > developing for irq-related deadlock. > > The tentative patch fix the potential deadlock by spin_lock_irqsave(). > > Signed-off-by: Chengfeng Ye I believe it's a false-positive. There is already a call spin_lock_irqsave(&chip->reg_lock, flags); beforehand. thanks, Takashi