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
Kconfig -rw-r--r-- 25.4 KB
Makefile -rw-r--r-- 3.1 KB
ad7266.c -rw-r--r-- 13.2 KB
ad7291.c -rw-r--r-- 13.6 KB
ad7298.c -rw-r--r-- 9.1 KB
ad7476.c -rw-r--r-- 7.2 KB
ad7766.c -rw-r--r-- 7.8 KB
ad7791.c -rw-r--r-- 11.3 KB
ad7793.c -rw-r--r-- 24.8 KB
ad7887.c -rw-r--r-- 8.7 KB
ad7923.c -rw-r--r-- 9.2 KB
ad799x.c -rw-r--r-- 21.1 KB
ad_sigma_delta.c -rw-r--r-- 13.0 KB
aspeed_adc.c -rw-r--r-- 7.9 KB
at91-sama5d2_adc.c -rw-r--r-- 14.6 KB
at91_adc.c -rw-r--r-- 40.3 KB
axp20x_adc.c -rw-r--r-- 14.9 KB
axp288_adc.c -rw-r--r-- 5.8 KB
bcm_iproc_adc.c -rw-r--r-- 18.0 KB
berlin2-adc.c -rw-r--r-- 10.5 KB
cc10001_adc.c -rw-r--r-- 11.2 KB
cpcap-adc.c -rw-r--r-- 27.4 KB
da9150-gpadc.c -rw-r--r-- 10.5 KB
envelope-detector.c -rw-r--r-- 11.0 KB
exynos_adc.c -rw-r--r-- 24.1 KB
fsl-imx25-gcq.c -rw-r--r-- 10.2 KB
hi8435.c -rw-r--r-- 13.9 KB
hx711.c -rw-r--r-- 12.0 KB
imx7d_adc.c -rw-r--r-- 15.9 KB
ina2xx-adc.c -rw-r--r-- 23.5 KB
lp8788_adc.c -rw-r--r-- 5.9 KB
lpc18xx_adc.c -rw-r--r-- 5.5 KB
lpc32xx_adc.c -rw-r--r-- 5.7 KB
ltc2485.c -rw-r--r-- 3.6 KB
ltc2497.c -rw-r--r-- 6.8 KB
max1027.c -rw-r--r-- 12.2 KB
max11100.c -rw-r--r-- 4.1 KB
max1118.c -rw-r--r-- 6.9 KB
max1363.c -rw-r--r-- 49.1 KB
max9611.c -rw-r--r-- 14.8 KB
mcp320x.c -rw-r--r-- 10.7 KB
mcp3422.c -rw-r--r-- 10.3 KB
men_z188_adc.c -rw-r--r-- 3.8 KB
meson_saradc.c -rw-r--r-- 31.6 KB
mt6577_auxadc.c -rw-r--r-- 7.6 KB
mxs-lradc-adc.c -rw-r--r-- 23.2 KB
nau7802.c -rw-r--r-- 14.5 KB
palmas_gpadc.c -rw-r--r-- 23.0 KB
qcom-pm8xxx-xoadc.c -rw-r--r-- 34.0 KB
qcom-spmi-iadc.c -rw-r--r-- 13.6 KB
qcom-spmi-vadc.c -rw-r--r-- 23.6 KB
qcom-vadc-common.c -rw-r--r-- 5.1 KB
qcom-vadc-common.h -rw-r--r-- 2.9 KB
rcar-gyroadc.c -rw-r--r-- 15.4 KB
rockchip_saradc.c -rw-r--r-- 9.9 KB
spear_adc.c -rw-r--r-- 9.3 KB
stm32-adc-core.c -rw-r--r-- 13.8 KB
stm32-adc-core.h -rw-r--r-- 1.9 KB
stm32-adc.c -rw-r--r-- 48.0 KB
stx104.c -rw-r--r-- 9.5 KB
sun4i-gpadc-iio.c -rw-r--r-- 19.6 KB
ti-adc081c.c -rw-r--r-- 6.3 KB
ti-adc0832.c -rw-r--r-- 8.4 KB
ti-adc084s021.c -rw-r--r-- 7.4 KB
ti-adc108s102.c -rw-r--r-- 8.8 KB
ti-adc12138.c -rw-r--r-- 12.6 KB
ti-adc128s052.c -rw-r--r-- 4.9 KB
ti-adc161s626.c -rw-r--r-- 6.2 KB
ti-ads1015.c -rw-r--r-- 17.9 KB
ti-ads7950.c -rw-r--r-- 12.8 KB
ti-ads8688.c -rw-r--r-- 11.6 KB
ti-tlc4541.c -rw-r--r-- 6.7 KB
ti_am335x_adc.c -rw-r--r-- 19.0 KB
twl4030-madc.c -rw-r--r-- 25.8 KB
twl6030-gpadc.c -rw-r--r-- 25.0 KB
vf610_adc.c -rw-r--r-- 24.1 KB
viperboard_adc.c -rw-r--r-- 3.7 KB
xilinx-xadc-core.c -rw-r--r-- 33.5 KB
xilinx-xadc-events.c -rw-r--r-- 5.8 KB
xilinx-xadc.h -rw-r--r-- 5.5 KB

back to top