linux/sound/core
Takashi Iwai a2ba2aff79 ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT
commit ba3021b2c7 upstream.

snd_timer_user_tselect() reallocates the queue buffer dynamically, but
it forgot to reset its indices.  Since the read may happen
concurrently with ioctl and snd_timer_user_tselect() allocates the
buffer via kmalloc(), this may lead to the leak of uninitialized
kernel-space data, as spotted via KMSAN:

  BUG: KMSAN: use of unitialized memory in snd_timer_user_read+0x6c4/0xa10
  CPU: 0 PID: 1037 Comm: probe Not tainted 4.11.0-rc5+ #2739
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
  Call Trace:
   __dump_stack lib/dump_stack.c:16
   dump_stack+0x143/0x1b0 lib/dump_stack.c:52
   kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:1007
   kmsan_check_memory+0xc2/0x140 mm/kmsan/kmsan.c:1086
   copy_to_user ./arch/x86/include/asm/uaccess.h:725
   snd_timer_user_read+0x6c4/0xa10 sound/core/timer.c:2004
   do_loop_readv_writev fs/read_write.c:716
   __do_readv_writev+0x94c/0x1380 fs/read_write.c:864
   do_readv_writev fs/read_write.c:894
   vfs_readv fs/read_write.c:908
   do_readv+0x52a/0x5d0 fs/read_write.c:934
   SYSC_readv+0xb6/0xd0 fs/read_write.c:1021
   SyS_readv+0x87/0xb0 fs/read_write.c:1018

This patch adds the missing reset of queue indices.  Together with the
previous fix for the ioctl/read race, we cover the whole problem.

Reported-by: Alexander Potapenko <glider@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2017-07-18 18:40:41 +01:00
..
oss ALSA: pcm: Fix potential deadlock in OSS emulation 2016-02-25 00:18:40 +00:00
seq ALSA: seq: Don't break snd_use_lock_sync() loop by timeout 2017-07-18 18:40:35 +01:00
compress_offload.c ALSA: compress: fix an integer overflow check 2016-08-22 22:38:27 +01:00
control.c ALSA: ctl: Stop notification after disconnection 2016-11-20 01:16:47 +00:00
control_compat.c ALSA: ctl: Fix ioctls for X32 ABI 2016-03-24 10:00:55 +00: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: hrtimer: Fix stall by hrtimer_cancel() 2016-02-02 19:09:58 +00:00
hwdep.c ALSA: Move EXPORT_SYMBOL() in appropriate places 2014-02-27 16:00:51 +01:00
hwdep_compat.c [PATCH] hwdep_compat missed __user annotations 2006-10-10 15:37:21 -07:00
info.c ALSA: core: fix buffer overflow in snd_info_get_line() 2014-10-05 13:40:53 -07: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: pcm: Free chmap at PCM free callback, too 2016-11-20 01:16:47 +00:00
pcm_compat.c ALSA: pcm: Fix snd_pcm_hw_params struct copy in compat mode 2016-02-02 19:09:58 +00: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 : Call kill_fasync() in stream lock 2017-02-23 03:54:48 +00: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: Don't leave PREPARED state after draining 2015-03-18 09:58:54 +00:00
pcm_timer.c ALSA: pcm: Use standard printk helpers 2014-02-14 08:14:15 +01:00
rawmidi.c ALSA: rawmidi: Fix possible deadlock with virmidi registration 2016-11-20 01:17:24 +00:00
rawmidi_compat.c ALSA: rawmidi: Fix ioctls X32 ABI 2016-03-24 10:00:55 +00:00
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: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT 2017-07-18 18:40:41 +01:00
timer_compat.c ALSA: timer: Fix ioctls for X32 ABI 2016-03-24 10:00:56 +00:00
vmaster.c ALSA: core: Use standard printk helpers 2014-02-14 08:14:15 +01:00