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 5F9BDEB64D9 for ; Tue, 27 Jun 2023 10:05:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbjF0KFb (ORCPT ); Tue, 27 Jun 2023 06:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbjF0KFA (ORCPT ); Tue, 27 Jun 2023 06:05:00 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9E2A423F for ; Tue, 27 Jun 2023 03:01:31 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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