ALSA: seq: Fix race at creating a queue
authorTakashi Iwai <tiwai@suse.de>
Wed, 8 Feb 2017 11:35:39 +0000 (12:35 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 16 Mar 2017 02:18:48 +0000 (02:18 +0000)
commit9ced4235b06ae65916f12f157e83bd985aa9460a
tree0186fc52eac67084ea21f4de46973d14bb3b0b1e
parent44a2c426d84453927e0280cd9b18162348b1d828
ALSA: seq: Fix race at creating a queue

commit 4842e98f26dd80be3623c4714a244ba52ea096a8 upstream.

When a sequencer queue is created in snd_seq_queue_alloc(),it adds the
new queue element to the public list before referencing it.  Thus the
queue might be deleted before the call of snd_seq_queue_use(), and it
results in the use-after-free error, as spotted by syzkaller.

The fix is to reference the queue object at the right time.

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_queue.c