ALSA: pcm: oss: Avoid potential buffer overflows
authorTakashi Iwai <tiwai@suse.de>
Wed, 4 Dec 2019 14:48:24 +0000 (15:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 21 Dec 2019 09:41:31 +0000 (10:41 +0100)
commit014af8ee5083c41dc9918590aa44c76ed5014069
treedacedf0c305c4ce8850567008648c3e548c824e9
parentc392b3a69ceddde55dea62a4bb83d542e60dfdbc
ALSA: pcm: oss: Avoid potential buffer overflows

commit 4cc8d6505ab82db3357613d36e6c58a297f57f7c upstream.

syzkaller reported an invalid access in PCM OSS read, and this seems
to be an overflow of the internal buffer allocated for a plugin.
Since the rate plugin adjusts its transfer size dynamically, the
calculation for the chained plugin might be bigger than the given
buffer size in some extreme cases, which lead to such an buffer
overflow as caught by KASAN.

Fix it by limiting the max transfer size properly by checking against
the destination size in each plugin transfer callback.

Reported-by: syzbot+f153bde47a62e0b05f83@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20191204144824.17801-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/oss/linear.c
sound/core/oss/mulaw.c
sound/core/oss/route.c