Revision 7e1d90f60a0d501c8503e636942ca704a454d910 authored by Daniel Mentz on 14 August 2017, 21:46:01 UTC, committed by Takashi Iwai on 15 August 2017, 06:02:35 UTC
commit 4842e98f26dd80be3623c4714a244ba52ea096a8 ("ALSA: seq: Fix race at
creating a queue") attempted to fix a race reported by syzkaller. That
fix has been described as follows:

"
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.
"

Even with that fix in place, syzkaller reported a use-after-free error.
It specifically pointed to the last instruction "return q->queue" in
snd_seq_queue_alloc(). The pointer q is being used after kfree() has
been called on it.

It turned out that there is still a small window where a race can
happen. The window opens at
snd_seq_ioctl_create_queue()->snd_seq_queue_alloc()->queue_list_add()
and closes at
snd_seq_ioctl_create_queue()->queueptr()->snd_use_lock_use(). Between
these two calls, a different thread could delete the queue and possibly
re-create a different queue in the same location in queue_list.

This change prevents this situation by calling snd_use_lock_use() from
snd_seq_queue_alloc() prior to calling queue_list_add(). It is then the
caller's responsibility to call snd_use_lock_free(&q->use_lock).

Fixes: 4842e98f26dd ("ALSA: seq: Fix race at creating a queue")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Daniel Mentz <danielmentz@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 8df4b00
History
File Mode Size
chips
devices
lpddr
maps
nand
onenand
parsers
spi-nor
tests
ubi
Kconfig -rw-r--r-- 11.7 KB
Makefile -rw-r--r-- 1.1 KB
afs.c -rw-r--r-- 6.1 KB
ar7part.c -rw-r--r-- 3.9 KB
bcm47xxpart.c -rw-r--r-- 8.1 KB
bcm63xxpart.c -rw-r--r-- 8.4 KB
cmdlinepart.c -rw-r--r-- 10.7 KB
ftl.c -rw-r--r-- 31.3 KB
inftlcore.c -rw-r--r-- 24.5 KB
inftlmount.c -rw-r--r-- 22.4 KB
mtd_blkdevs.c -rw-r--r-- 13.4 KB
mtdblock.c -rw-r--r-- 9.7 KB
mtdblock_ro.c -rw-r--r-- 2.5 KB
mtdchar.c -rw-r--r-- 27.0 KB
mtdconcat.c -rw-r--r-- 22.8 KB
mtdcore.c -rw-r--r-- 49.1 KB
mtdcore.h -rw-r--r-- 876 bytes
mtdoops.c -rw-r--r-- 11.8 KB
mtdpart.c -rw-r--r-- 26.7 KB
mtdsuper.c -rw-r--r-- 5.5 KB
mtdswap.c -rw-r--r-- 35.2 KB
nftlcore.c -rw-r--r-- 23.0 KB
nftlmount.c -rw-r--r-- 26.0 KB
ofpart.c -rw-r--r-- 5.6 KB
redboot.c -rw-r--r-- 8.2 KB
rfd_ftl.c -rw-r--r-- 18.3 KB
sm_ftl.c -rw-r--r-- 30.2 KB
sm_ftl.h -rw-r--r-- 2.5 KB
ssfdc.c -rw-r--r-- 11.3 KB

back to top