]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ALSA: usb-audio: fix possible hang and overflow in parse_uac2_sample_rate_range()
authorXi Wang <xi.wang@gmail.com>
Sun, 8 Jan 2012 14:02:52 +0000 (09:02 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Jun 2013 19:46:48 +0000 (12:46 -0700)
commit44f059fb742aac78cffdab5e0d8fe0c9910c1ded
treeb3b6fc1cf6d587aff9061d90c2a0b95cc9d16f88
parent3b1a317977a8d16d743e8f85ed9a5a7f668b61d5
ALSA: usb-audio: fix possible hang and overflow in parse_uac2_sample_rate_range()

commit 4fa0e81b83503900be277e6273a79651b375e288 upstream.

A malicious USB device may feed in carefully crafted min/max/res values,
so that the inner loop in parse_uac2_sample_rate_range() could run for
a long time or even never terminate, e.g., given max = INT_MAX.

Also nr_rates could be a large integer, which causes an integer overflow
in the subsequent call to kmalloc() in parse_audio_format_rates_v2().
Thus, kmalloc() would allocate a smaller buffer than expected, leading
to a memory corruption.

To exploit the two vulnerabilities, an attacker needs physical access
to the machine to plug in a malicious USB device.

This patch makes two changes.

1) The type of "rate" is changed to unsigned int, so that the loop could
   stop once "rate" is larger than INT_MAX.

2) Limit nr_rates to 1024.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/usb/format.c