ALSA: timer: Fix race among timer ioctls
authorTakashi Iwai <tiwai@suse.de>
Wed, 13 Jan 2016 16:48:01 +0000 (17:48 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 13 Feb 2016 10:34:09 +0000 (10:34 +0000)
commit12f88515e0e99a220afdfaeeeedf2fe206fbdc24
tree71a2866640b7c094727b57d6cbc3de102927597b
parent0e8f916d7dc9170ab2ef4b9a9ed19b640720029b
ALSA: timer: Fix race among timer ioctls

commit af368027a49a751d6ff4ee9e3f9961f35bb4fede upstream.

ALSA timer ioctls have an open race and this may lead to a
use-after-free of timer instance object.  A simplistic fix is to make
each ioctl exclusive.  We have already tread_sem for controlling the
tread, and extend this as a global mutex to be applied to each ioctl.

The downside is, of course, the worse concurrency.  But these ioctls
aren't to be parallel accessible, in anyway, so it should be fine to
serialize there.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-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/timer.c