diff options
author | Xi Wang <xi.wang@gmail.com> | 2012-02-14 14:18:48 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-02-15 17:58:15 +0400 |
commit | 8866f405efd4171f9d9c91901d2dd02f01bacb60 (patch) | |
tree | 414b07ed6d979f9aad804dc16b4f280247741eaf /sound/usb/format.c | |
parent | 27c3afe6e1cf129faac90405121203962da08ff4 (diff) | |
download | linux-8866f405efd4171f9d9c91901d2dd02f01bacb60.tar.xz |
ALSA: usb-audio: avoid integer overflow in create_fixed_stream_quirk()
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>
Diffstat (limited to 'sound/usb/format.c')
-rw-r--r-- | sound/usb/format.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sound/usb/format.c b/sound/usb/format.c index e09aba19375c..ddfef57c4c9f 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -209,8 +209,6 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof return 0; } -#define MAX_UAC2_NR_RATES 1024 - /* * Helper function to walk the array of sample rate triplets reported by * the device. The problem is that we need to parse whole array first to @@ -255,7 +253,7 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets, fp->rates |= snd_pcm_rate_to_rate_bit(rate); nr_rates++; - if (nr_rates >= MAX_UAC2_NR_RATES) { + if (nr_rates >= MAX_NR_RATES) { snd_printk(KERN_ERR "invalid uac2 rates\n"); break; } |