linux/sound/core
Takashi Iwai 88fa5aa1ae ALSA: timer: Fix UBSAN warning at SNDRV_TIMER_IOCTL_NEXT_DEVICE ioctl
commit b41f794f28 upstream.

The kernel may spew a WARNING about UBSAN undefined behavior at
handling ALSA timer ioctl SNDRV_TIMER_IOCTL_NEXT_DEVICE:

UBSAN: Undefined behaviour in sound/core/timer.c:1524:19
signed integer overflow:
2147483647 + 1 cannot be represented in type 'int'
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x122/0x1c8 lib/dump_stack.c:113
 ubsan_epilogue+0x12/0x86 lib/ubsan.c:159
 handle_overflow+0x1c2/0x21f lib/ubsan.c:190
 __ubsan_handle_add_overflow+0x2a/0x31 lib/ubsan.c:198
 snd_timer_user_next_device sound/core/timer.c:1524 [inline]
 __snd_timer_user_ioctl+0x204d/0x2520 sound/core/timer.c:1939
 snd_timer_user_ioctl+0x67/0x95 sound/core/timer.c:1994
 ....

It happens only when a value with INT_MAX is passed, as we're
incrementing it unconditionally.  So the fix is trivial, check the
value with INT_MAX.  Although the bug itself is fairly harmless, it's
better to fix it so that fuzzers won't hit this again later.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200213
Reported-and-tested-by: Team OWL337 <icytxw@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
[bwh: Backported to 3.16: adjust context, indentation]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-11-20 18:05:27 +00:00
..
oss ALSA: pcm: Fix endless loop for XRUN recovery in OSS emulation 2018-10-21 08:45:17 +01:00
seq ALSA: seq: Fix races at MIDI encoding in snd_virmidi_output_trigger() 2018-10-21 08:45:47 +01:00
compress_offload.c ALSA: compress: fix an integer overflow check 2016-08-22 22:38:27 +01:00
control.c ALSA: core: Fix unexpected error at replacing user TLV 2017-11-11 13:33:24 +00:00
control_compat.c ALSA: control: fix a redundant-copy issue 2018-10-21 08:46:03 +01:00
ctljack.c ALSA: hda - Add missing inclusion of linux/export.h 2011-11-16 14:28:33 +01:00
device.c ALSA: core: Assure control device to be registered at last 2018-11-20 18:04:56 +00:00
hrtimer.c ALSA: timer: Limit max instances per timer 2018-01-01 20:52:05 +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: Fix UAF at PCM release via PCM timer access 2018-10-21 08:45:09 +01:00
pcm_compat.c ALSA: pcm: Check PCM state at xfern compat ioctl 2018-10-21 08:45:50 +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: Remove yet superfluous WARN_ON() 2018-03-03 15:52:21 +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: core: Report audio_tstamp in snd_pcm_sync_ptr 2018-10-21 08:45:37 +01:00
pcm_timer.c ALSA: pcm: Use standard printk helpers 2014-02-14 08:14:15 +01:00
rawmidi.c ALSA: rawmidi: Change resized buffers atomically 2018-09-25 23:47:30 +01:00
rawmidi_compat.c ALSA: rawmidi: Fix missing input substream checks in compat ioctls 2018-10-21 08:45:33 +01: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 UBSAN warning at SNDRV_TIMER_IOCTL_NEXT_DEVICE ioctl 2018-11-20 18:05:27 +00:00
timer_compat.c ALSA: timer: Remove kernel warning at compat ioctl error paths 2018-02-13 18:42:27 +00:00
vmaster.c ALSA: core: Use standard printk helpers 2014-02-14 08:14:15 +01:00