linux-stable/sound/core
Lars-Peter Clausen 82262a4662 ALSA: control: Fix replacing user controls
There are two issues with the current implementation for replacing user
controls. The first is that the code does not check if the control is actually a
user control and neither does it check if the control is owned by the process
that tries to remove it. That allows userspace applications to remove arbitrary
controls, which can cause a user after free if a for example a driver does not
expect a control to be removed from under its feed.

The second issue is that on one hand when a control is replaced the
user_ctl_count limit is not checked and on the other hand the user_ctl_count is
increased (even though the number of user controls does not change). This allows
userspace, once the user_ctl_count limit as been reached, to repeatedly replace
a control until user_ctl_count overflows. Once that happens new controls can be
added effectively bypassing the user_ctl_count limit.

Both issues can be fixed by instead of open-coding the removal of the control
that is to be replaced to use snd_ctl_remove_user_ctl(). This function does
proper permission checks as well as decrements user_ctl_count after the control
has been removed.

Note that by using snd_ctl_remove_user_ctl() the check which returns -EBUSY at
beginning of the function if the control already exists is removed. This is not
a problem though since the check is quite useless, because the lock that is
protecting the control list is released between the check and before adding the
new control to the list, which means that it is possible that a different
control with the same settings is added to the list after the check. Luckily
there is another check that is done while holding the lock in snd_ctl_add(), so
we'll rely on that to make sure that the same control is not added twice.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-06-18 15:12:49 +02:00
..
oss ALSA: oss: Use standard printk helpers 2014-02-14 08:14:17 +01:00
seq ALSA: seq: Continue broadcasting events to ports if one of them fails 2014-06-04 17:30:58 +02:00
compress_offload.c ALSA: compress: Pass through return value of open ops callback 2014-03-19 15:46:24 +01:00
control.c ALSA: control: Fix replacing user controls 2014-06-18 15:12:49 +02:00
control_compat.c ALSA: control: Use standard printk helpers 2014-02-14 08:14:14 +01:00
ctljack.c ALSA: hda - Add missing inclusion of linux/export.h 2011-11-16 14:28:33 +01:00
device.c ALSA: Clean up snd_device_*() codes 2014-02-25 12:12:52 +01:00
hrtimer.c ALSA: timer: Use standard printk helpers 2014-02-14 08:14:17 +01:00
hwdep.c ALSA: Move EXPORT_SYMBOL() in appropriate places 2014-02-27 16:00:51 +01:00
hwdep_compat.c
info.c ALSA: core: Use standard printk helpers 2014-02-14 08:14:15 +01:00
info_oss.c ALSA: remove the main version information 2012-09-04 11:38:32 +02:00
init.c ALSA: control: Protect user controls against concurrent access 2014-06-18 15:12:33 +02:00
isadma.c ALSA: core: Use standard printk helpers 2014-02-14 08:14:15 +01:00
jack.c ALSA: jack: Unregister input device at disconnection 2013-11-14 17:22:45 +01:00
Kconfig ALSA: core: allow SND_DMAENGINE_PCM use from modules 2013-08-15 18:28:42 +01:00
Makefile ALSA: Merge memalloc code into snd-pcm module 2014-01-09 08:12:57 +01:00
memalloc.c ALSA: core: Use standard printk helpers 2014-02-14 08:14:15 +01:00
memory.c ALSA: add/change some comments describing function return values 2013-03-12 08:32:53 +01:00
misc.c sound: use printk_get_level and printk_skip_level 2012-07-30 17:25:14 -07:00
pcm.c ALSA: Create sysfs attribute files via groups 2014-02-25 12:12:49 +01:00
pcm_compat.c ALSA: core: fix 64-bit SNDRV_PCM_IOCTL_STATUS ABI breakage 2012-10-28 09:52:37 +01:00
pcm_dmaengine.c ALSA: pcm_dmaengine: Add check during device suspend 2014-05-19 11:31:24 +02:00
pcm_lib.c ALSA: pcm: 'BUG:' message unnecessarily triggers kerneloops 2014-04-16 16:20:59 +02:00
pcm_memory.c ALSA: PCM: Warn when buffer preallocation fails 2014-01-11 11:04:23 +01:00
pcm_misc.c ALSA: Add helper function for intersecting two rate masks 2014-01-14 20:42:34 +00:00
pcm_native.c ALSA: pcm: Use standard printk helpers 2014-02-14 08:14:15 +01:00
pcm_timer.c ALSA: pcm: Use standard printk helpers 2014-02-14 08:14:15 +01:00
rawmidi.c ALSA: Move EXPORT_SYMBOL() in appropriate places 2014-02-27 16:00:51 +01:00
rawmidi_compat.c
rtctimer.c ALSA: timer: Use standard printk helpers 2014-02-14 08:14:17 +01:00
sgbuf.c ALSA: Make snd_sgbuf_get_{ptr|addr}() available for non-SG cases 2012-09-23 11:24:42 +02:00
sound.c ALSA: Create sysfs attribute files via groups 2014-02-25 12:12:49 +01:00
sound_oss.c ALSA: Use standard device refcount for card accounting 2014-02-14 08:14:13 +01:00
timer.c ALSA: core: Use ktime_get_ts() 2014-06-12 12:58:16 +02:00
timer_compat.c ALSA: Kill snd_assert() in sound/core/* 2008-08-13 11:46:35 +02:00
vmaster.c ALSA: core: Use standard printk helpers 2014-02-14 08:14:15 +01:00