Commit 7147be7a authored by Takashi Iwai's avatar Takashi Iwai Committed by Khalid Elmously

ALSA: line6: Fix write on zero-sized buffer

BugLink: https://bugs.launchpad.net/bugs/1860681

commit 34501219 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
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
[bwh: Backported to 4.4: Driver doesn't support asymmetrical packet
 sizes, so only check snd_line6_pcm::max_packet_size]
Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent 87874179
...@@ -529,6 +529,11 @@ int line6_init_pcm(struct usb_line6 *line6, ...@@ -529,6 +529,11 @@ int line6_init_pcm(struct usb_line6 *line6,
usb_rcvisocpipe(line6->usbdev, ep_read), 0), usb_rcvisocpipe(line6->usbdev, ep_read), 0),
usb_maxpacket(line6->usbdev, usb_maxpacket(line6->usbdev,
usb_sndisocpipe(line6->usbdev, ep_write), 1)); usb_sndisocpipe(line6->usbdev, ep_write), 1));
if (!line6pcm->max_packet_size) {
dev_err(line6pcm->line6->ifcdev,
"cannot get proper max packet size\n");
return -EINVAL;
}
spin_lock_init(&line6pcm->out.lock); spin_lock_init(&line6pcm->out.lock);
spin_lock_init(&line6pcm->in.lock); spin_lock_init(&line6pcm->in.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment