ALSA: seq: Fix race at creating a queue
authorTakashi Iwai <tiwai@suse.de>
Wed, 8 Feb 2017 11:35:39 +0000 (12:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Feb 2017 23:22:52 +0000 (15:22 -0800)
commite5f20a3fd6dbdc3db409aa786899e60754562e1a
tree772f217649ae0e903ca034c4e08953ce9a1bf1b5
parent010ada0cfcb9743f141ee7d7a22df063786129da
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/seq/seq_queue.c