linux/sound/core
Takashi Iwai 0c4190b41a ALSA: oss: Fix PCM OSS buffer allocation overflow
commit efb6402c3c4a7c26d97c92d70186424097b6e366 upstream.

We've got syzbot reports hitting INT_MAX overflow at vmalloc()
allocation that is called from snd_pcm_plug_alloc().  Although we
apply the restrictions to input parameters, it's based only on the
hw_params of the underlying PCM device.  Since the PCM OSS layer
allocates a temporary buffer for the data conversion, the size may
become unexpectedly large when more channels or higher rates is given;
in the reported case, it went over INT_MAX, hence it hits WARN_ON().

This patch is an attempt to avoid such an overflow and an allocation
for too large buffers.  First off, it adds the limit of 1MB as the
upper bound for period bytes.  This must be large enough for all use
cases, and we really don't want to handle a larger temporary buffer
than this size.  The size check is performed at two places, where the
original period bytes is calculated and where the plugin buffer size
is calculated.

In addition, the driver uses array_size() and array3_size() for
multiplications to catch overflows for the converted period size and
buffer bytes.

Reported-by: syzbot+72732c532ac1454eeee9@syzkaller.appspotmail.com
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/00000000000085b1b305da5a66f3@google.com
Link: https://lore.kernel.org/r/20220318082036.29699-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-28 08:46:46 +02:00
..
oss ALSA: oss: Fix PCM OSS buffer allocation overflow 2022-03-28 08:46:46 +02:00
seq ALSA: seq: Set upper limit of processed events 2022-01-27 09:19:48 +01:00
Kconfig
Makefile ALSA: ISA: not for M68K 2021-11-26 10:47:16 +01:00
compress_offload.c
control.c
control_compat.c ALSA: ctl: Fix copy of updated id with element read/write 2021-12-14 14:49:00 +01:00
ctljack.c
device.c
hrtimer.c
hwdep.c
hwdep_compat.c
info.c
info_oss.c
init.c ALSA: core: remove redundant spin_lock pair in snd_card_disconnect 2021-05-14 09:44:26 +02:00
isadma.c
jack.c ALSA: jack: Add missing rwsem around snd_ctl_remove() calls 2022-01-27 09:19:37 +01:00
memalloc.c ALSA: core: memalloc: add page alignment for iram 2020-12-30 11:51:34 +01:00
memory.c
misc.c
pcm.c ALSA: PCM: Add missing rwsem around snd_ctl_remove() calls 2022-01-27 09:19:37 +01:00
pcm_compat.c
pcm_dmaengine.c
pcm_drm_eld.c
pcm_iec958.c
pcm_lib.c ALSA: pcm: fix divide error in snd_pcm_lib_ioctl 2021-09-12 08:56:40 +02:00
pcm_local.h
pcm_memory.c
pcm_misc.c
pcm_native.c ALSA: pcm: Add stream lock during PCM reset ioctl operations 2022-03-28 08:46:45 +02:00
pcm_param_trace.h
pcm_timer.c
pcm_trace.h
rawmidi.c ALSA: rawmidi: Access runtime->avail always in spinlock 2021-01-06 14:48:38 +01:00
rawmidi_compat.c
seq_device.c ALSA: seq: Fix a potential UAF by wrong private_free call order 2021-10-20 11:40:12 +02:00
sgbuf.c
sound.c
sound_oss.c
timer.c ALSA: timer: Unconditionally unlink slave instances, too 2021-11-17 09:48:19 +01:00
timer_compat.c
vmaster.c