linux-stable/sound
Takashi Iwai d8a2dca040 ALSA: control: Fix race between adding and removing a user element
commit e1a7bfe380 upstream.

The procedure for adding a user control element has some window opened
for race against the concurrent removal of a user element.  This was
caught by syzkaller, hitting a KASAN use-after-free error.

This patch addresses the bug by wrapping the whole procedure to add a
user control element with the card->controls_rwsem, instead of only
around the increment of card->user_ctl_count.

This required a slight code refactoring, too.  The function
snd_ctl_add() is split to two parts: a core function to add the
control element and a part calling it.  The former is called from the
function for adding a user control element inside the controls_rwsem.

One change to be noted is that snd_ctl_notify() for adding a control
element gets called inside the controls_rwsem as well while it was
called outside the rwsem.  But this should be OK, as snd_ctl_notify()
takes another (finer) rwlock instead of rwsem, and the call of
snd_ctl_notify() inside rwsem is already done in another code path.

Reported-by: syzbot+dc09047bce3820621ba2@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05 19:32:08 +01:00
..
ac97 ALSA: ac97: fix unbalanced pm_runtime_enable 2018-08-19 18:37:04 +02:00
aoa ALSA: snd-aoa: add of_node_put() in error path 2018-06-29 20:35:14 +02:00
arm ASoC: pxa2xx-pcm-lib: fix indenting 2018-06-29 12:05:05 +01:00
atmel
core ALSA: control: Fix race between adding and removing a user element 2018-12-05 19:32:08 +01:00
drivers ALSA: opl3: Mark expected switch fall-through 2018-08-08 21:40:14 +02:00
firewire ALSA: fireworks: fix memory leak of response buffer at error path 2018-09-17 13:41:14 +02:00
hda ALSA: hda: Fix the audio-component completion timeout 2018-09-20 08:36:03 +02:00
i2c ALSA: i2c: Remove empty init and exit 2018-08-03 16:11:43 +02:00
isa ALSA: wss: Fix invalid snd_free_pages() at error path 2018-12-05 19:32:08 +01:00
mips ALSA: pcm: Nuke snd_pcm_lib_mmap_vmalloc() 2018-07-18 08:24:29 +02:00
oss treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
parisc
pci ALSA: ac97: Fix incorrect bit shift at AC97-SPSA control write 2018-12-05 19:32:08 +01:00
pcmcia Merge branch 'for-linus' into topic/virmidi 2018-07-29 22:39:29 +02:00
ppc powerpc/ps3: Set driver coherent_dma_mask 2018-07-20 12:50:37 +10:00
sh
soc ASoC: sta32x: set ->component pointer in private struct 2018-11-13 11:08:42 -08:00
sparc sound: Use octal not symbolic permissions 2018-05-28 11:27:20 +02:00
spi
synth ALSA: synth: Remove empty init and exit 2018-08-03 16:11:53 +02:00
usb ALSA: usb-audio: Mark expected switch fall-through 2018-08-09 08:52:33 +02:00
x86 ALSA: intel_hdmi: remove redundant variable cfg_val 2018-08-06 21:36:14 +02:00
xen ALSA: xen: Use standard pcm_format_to_bits() for ALSA format bits 2018-07-27 09:05:34 +02:00
ac97_bus.c
Kconfig ALSA: xen-front: Introduce Xen para-virtualized sound frontend driver 2018-05-16 12:58:36 +02:00
last.c
Makefile ALSA: xen-front: Introduce Xen para-virtualized sound frontend driver 2018-05-16 12:58:36 +02:00
sound_core.c sound: Use octal not symbolic permissions 2018-05-28 11:27:20 +02:00