ALSA: line6: Fix write on zero-sized buffer
authorTakashi Iwai <tiwai@suse.de>
Tue, 2 Jul 2019 18:07:21 +0000 (20:07 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Jul 2019 07:53:42 +0000 (09:53 +0200)
commit7f52af5e9baa9c478edcecdd4058eeef2835b1c3
treeb69f5cf4fa82d0ff91b728affac3cb97be876525
parent3663bf2baa97c15ede268c095b4b65f2323adf6e
ALSA: line6: Fix write on zero-sized buffer

commit 3450121997ce872eb7f1248417225827ea249710 upstream.

LINE6 drivers allocate the buffers based on the value returned from
usb_maxpacket() calls.  The manipulated device may return zero for
this, and this results in the kmalloc() with zero size (and it may
succeed) while the other part of the driver code writes the packet
data with the fixed size -- which eventually overwrites.

This patch adds a simple sanity check for the invalid buffer size for
avoiding that problem.

Reported-by: syzbot+219f00fb49874dcaea17@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/line6/pcm.c