]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC
authorTakashi Iwai <tiwai@suse.de>
Mon, 5 Sep 2022 06:07:14 +0000 (08:07 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 5 Sep 2022 13:01:22 +0000 (15:01 +0200)
commit86b26d1587e33463017117e35e5d7e4a4018c3ff
tree5914cf974503f3799708d61372ef869a384be9f1
parentc25ca73d3991952bf66076f86165630bcda1a44c
ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC

There is a small race window at snd_pcm_oss_sync() that is called from
OSS PCM SNDCTL_DSP_SYNC ioctl; namely the function calls
snd_pcm_oss_make_ready() at first, then takes the params_lock mutex
for the rest.  When the stream is set up again by another thread
between them, it leads to inconsistency, and may result in unexpected
results such as NULL dereference of OSS buffer as a fuzzer spotted
recently.

The fix is simply to cover snd_pcm_oss_make_ready() call into the same
params_lock mutex with snd_pcm_oss_make_ready_locked() variant.

Reported-and-tested-by: butt3rflyh4ck <butterflyhuangxx@gmail.com>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com
Link: https://lore.kernel.org/r/20220905060714.22549-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/oss/pcm_oss.c