ALSA: seq: Fix yet another races among ALSA timer accesses
authorTakashi Iwai <tiwai@suse.de>
Sat, 30 Jan 2016 22:30:25 +0000 (23:30 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 27 Feb 2016 14:28:45 +0000 (14:28 +0000)
commitef5fde817c9c892ee0a613fb54697fb35aa0e5e6
tree88411f84be398ecce221ab5c7d73de1aa63bfea3
parentbec0f5d5ed73c8058aee745000919fba65105a03
ALSA: seq: Fix yet another races among ALSA timer accesses

commit 2cdc7b636d55cbcf42e1e6c8accd85e62d3e9ae8 upstream.

ALSA sequencer may open/close and control ALSA timer instance
dynamically either via sequencer events or direct ioctls.  These are
done mostly asynchronously, and it may call still some timer action
like snd_timer_start() while another is calling snd_timer_close().
Since the instance gets removed by snd_timer_close(), it may lead to
a use-after-free.

This patch tries to address such a race by protecting each
snd_timer_*() call via the existing spinlock and also by avoiding the
access to timer during close call.

BugLink: http://lkml.kernel.org/r/CACT4Y+Z6RzW5MBr-HUdV-8zwg71WQfKTdPpYGvOeS7v4cyurNQ@mail.gmail.com
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/core/seq/seq_timer.c