From: Sasha Levin <sashal@kernel.org>
To: Takashi Iwai <tiwai@suse.de>
Cc: gregkh@linuxfoundation.org, kirill.shutemov@linux.intel.com,
stable@vger.kernel.org
Subject: Re: FAILED: patch "[PATCH] ALSA: timer: Fix mutex deadlock at releasing card" failed to apply to 4.19-stable tree
Date: Mon, 4 Nov 2019 07:25:38 -0500 [thread overview]
Message-ID: <20191104122537.GC4787@sasha-vm> (raw)
In-Reply-To: <s5hmudbx6rd.wl-tiwai@suse.de>
On Mon, Nov 04, 2019 at 11:42:14AM +0100, Takashi Iwai wrote:
>On Mon, 04 Nov 2019 11:30:20 +0100,
>Sasha Levin wrote:
>>
>> On Sun, Nov 03, 2019 at 06:40:59PM +0100, gregkh@linuxfoundation.org wrote:
>> >
>> >The patch below does not apply to the 4.19-stable tree.
>> >If someone wants it applied there, or to any other stable or longterm
>> >tree, then please email the backport, including the original git commit
>> >id to <stable@vger.kernel.org>.
>> >
>> >thanks,
>> >
>> >greg k-h
>> >
>> >------------------ original commit in Linus's tree ------------------
>> >
>> >From a39331867335d4a94b6165e306265c9e24aca073 Mon Sep 17 00:00:00 2001
>> >From: Takashi Iwai <tiwai@suse.de>
>> >Date: Wed, 30 Oct 2019 22:42:57 +0100
>> >Subject: [PATCH] ALSA: timer: Fix mutex deadlock at releasing card
>> >
>> >When a card is disconnected while in use, the system waits until all
>> >opened files are closed then releases the card. This is done via
>> >put_device() of the card device in each device release code.
>> >
>> >The recently reported mutex deadlock bug happens in this code path;
>> >snd_timer_close() for the timer device deals with the global
>> >register_mutex and it calls put_device() there. When this timer
>> >device is the last one, the card gets freed and it eventually calls
>> >snd_timer_free(), which has again the protection with the global
>> >register_mutex -- boom.
>> >
>> >Basically put_device() call itself is race-free, so a relative simple
>> >workaround is to move this put_device() call out of the mutex. For
>> >achieving that, in this patch, snd_timer_close_locked() got a new
>> >argument to store the card device pointer in return, and each caller
>> >invokes put_device() with the returned object after the mutex unlock.
>> >
>> >Reported-and-tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>> >Cc: <stable@vger.kernel.org>
>> >Signed-off-by: Takashi Iwai <tiwai@suse.de>
>>
>> Looks like this was introduced by 41672c0c24a6 ("ALSA: timer: Simplify
>> error path in snd_timer_open()"), which means it's not needed on 4.19 or
>> older.
>
>We'd still need a similar fix, as the code path in question is about
>closing, not opening the device. If backporting the commit
>41672c0c24a6 makes the fix cleanly applicable, it'd be worth to
>backport both.
>
>If not, I can submit a modified 4.19.y patch, too.
Yeah, it works for 4.19 and 4.14, I've queued it up.
The 4.9 backport requires two more commits:
9b7d869ee5a7 ("ALSA: timer: Limit max instances per timer")
988563929d5b ("ALSA: timer: Follow standard EXPORT_SYMBOL() declarations")
Does it makes sense to take them?
--
Thanks,
Sasha
next prev parent reply other threads:[~2019-11-04 12:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-03 17:40 FAILED: patch "[PATCH] ALSA: timer: Fix mutex deadlock at releasing card" failed to apply to 4.19-stable tree gregkh
2019-11-04 10:30 ` Sasha Levin
2019-11-04 10:42 ` Takashi Iwai
2019-11-04 12:25 ` Sasha Levin [this message]
2019-11-04 13:20 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191104122537.GC4787@sasha-vm \
--to=sashal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox