ALSA: usb-audio: avoid integer overflow in create_fixed_stream_quirk()
authorXi Wang <xi.wang@gmail.com>
Tue, 14 Feb 2012 10:18:48 +0000 (05:18 -0500)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 19 Jun 2013 01:16:42 +0000 (02:16 +0100)
commit2c8d23aefec3e8b6a8717a0ea469c332a03b1a8a
treed04fb7578cbc79c714dce22d0bcf371ed55f32f8
parentc25a53781f61c78bf2a2fa308bbd35b42ba346f6
ALSA: usb-audio: avoid integer overflow in create_fixed_stream_quirk()

commit 8866f405efd4171f9d9c91901d2dd02f01bacb60 upstream.

A malicious USB device could feed in a large nr_rates value.  This would
cause the subsequent call to kmemdup() to allocate a smaller buffer than
expected, leading to out-of-bounds access.

This patch validates the nr_rates value and reuses the limit introduced
in commit 4fa0e81b ("ALSA: usb-audio: fix possible hang and overflow
in parse_uac2_sample_rate_range()").

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
sound/usb/card.h
sound/usb/format.c
sound/usb/quirks.c