ALSA: timer: Fix race between read and ioctl
authorTakashi Iwai <tiwai@suse.de>
Fri, 2 Jun 2017 13:03:38 +0000 (15:03 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 18 Jul 2017 17:38:45 +0000 (18:38 +0100)
commit7aba7242b83b6e9a56a8eb875d669cfab4eff542
tree717f129a6feb52cb5bfab7c2502f74088f6670b4
parentcea299eb189fca09c413432b807abd607385b3bc
ALSA: timer: Fix race between read and ioctl

commit d11662f4f798b50d8c8743f433842c3e40fe3378 upstream.

The read from ALSA timer device, the function snd_timer_user_tread(),
may access to an uninitialized struct snd_timer_user fields when the
read is concurrently performed while the ioctl like
snd_timer_user_tselect() is invoked.  We have already fixed the races
among ioctls via a mutex, but we seem to have forgotten the race
between read vs ioctl.

This patch simply applies (more exactly extends the already applied
range of) tu->ioctl_lock in snd_timer_user_tread() for closing the
race window.

Reported-by: Alexander Potapenko <glider@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/core/timer.c