]> www.infradead.org Git - users/jedix/linux-maple.git/commit
ALSA: hrtimer: Fix stall by hrtimer_cancel()
authorTakashi Iwai <tiwai@suse.de>
Mon, 18 Jan 2016 12:52:47 +0000 (13:52 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:43:16 +0000 (15:43 -0700)
commit29e893dc4f46b31146dbef017c178a3b8b984546
treec704f5a20988f6877be9118be3697cca19ad8f4d
parent2a603956c034bb62a4979de88307c09392d57528
ALSA: hrtimer: Fix stall by hrtimer_cancel()

Orabug: 23330533

commit 2ba1fe7a06d3624f9a7586d672b55f08f7c670f3 upstream.

hrtimer_cancel() waits for the completion from the callback, thus it
must not be called inside the callback itself.  This was already a
problem in the past with ALSA hrtimer driver, and the early commit
[fcfdebe70759: ALSA: hrtimer - Fix lock-up] tried to address it.

However, the previous fix is still insufficient: it may still cause a
lockup when the ALSA timer instance reprograms itself in its callback.
Then it invokes the start function even in snd_timer_interrupt() that
is called in hrtimer callback itself, results in a CPU stall.  This is
no hypothetical problem but actually triggered by syzkaller fuzzer.

This patch tries to fix the issue again.  Now we call
hrtimer_try_to_cancel() at both start and stop functions so that it
won't fall into a deadlock, yet giving some chance to cancel the queue
if the functions have been called outside the callback.  The proper
hrtimer_cancel() is called in anyway at closing, so this should be
enough.

Reported-and-tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 965b1203f399676ac4989a0876336e212a71085b)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
sound/core/hrtimer.c