From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, "Xi Wang" <xi.wang@gmail.com>,
"Takashi Iwai" <tiwai@suse.de>
Subject: [13/83] ALSA: usb-audio: fix possible hang and overflow in parse_uac2_sample_rate_range()
Date: Sun, 16 Jun 2013 23:01:37 +0100 [thread overview]
Message-ID: <lsq.1371420097.12456539@decadent.org.uk> (raw)
In-Reply-To: <lsq.1371420097.958132574@decadent.org.uk>
3.2.47-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Xi Wang <xi.wang@gmail.com>
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>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
sound/usb/format.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sound/usb/format.c b/sound/usb/format.c
index 89421d1..e09aba1 100644
--- a/sound/usb/format.c
+++ b/sound/usb/format.c
@@ -209,6 +209,8 @@ 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
@@ -226,7 +228,7 @@ static int parse_uac2_sample_rate_range(struct audioformat *fp, int nr_triplets,
int min = combine_quad(&data[2 + 12 * i]);
int max = combine_quad(&data[6 + 12 * i]);
int res = combine_quad(&data[10 + 12 * i]);
- int rate;
+ unsigned int rate;
if ((max < 0) || (min < 0) || (res < 0) || (max < min))
continue;
@@ -253,6 +255,10 @@ 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) {
+ snd_printk(KERN_ERR "invalid uac2 rates\n");
+ break;
+ }
/* avoid endless loop */
if (res == 0)
next prev parent reply other threads:[~2013-06-16 22:31 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-16 22:01 [00/83] 3.2.47-rc1 review Ben Hutchings
2013-06-16 22:01 ` [24/83] xen-netfront: reduce gso_max_size to account for max TCP header Ben Hutchings
2013-06-16 22:01 ` [11/83] tg3: Add New 5719 Read DMA workaround Ben Hutchings
2013-06-16 22:01 ` [18/83] xen-netback: coalesce slots in TX path and fix regressions Ben Hutchings
2013-06-16 22:01 ` [23/83] net: Add net_ratelimited_function and net_<level>_ratelimited macros Ben Hutchings
2013-06-16 22:01 ` [29/83] thinkpad-acpi: recognize latest V-Series using DMI_BIOS_VENDOR Ben Hutchings
2013-06-16 22:01 ` [16/83] netback: remove redundant assignment Ben Hutchings
2013-06-16 22:01 ` [26/83] xen/events: Handle VIRQ_TIMER before any other hardirq in event loop Ben Hutchings
2013-06-16 22:01 ` [27/83] b43legacy: Fix crash on unload when firmware not available Ben Hutchings
2013-06-16 22:01 ` [30/83] ftrace: Move ftrace_filter_lseek out of CONFIG_DYNAMIC_FTRACE section Ben Hutchings
2013-06-16 22:01 ` [05/83] cifs: fix potential buffer overrun when composing a new options string Ben Hutchings
2013-06-16 22:01 ` [03/83] libata: make ata_exec_internal_sg honor DMADIR Ben Hutchings
2013-06-16 22:01 ` [20/83] xen-netback: remove redundent parameter in netbk_count_requests Ben Hutchings
2013-06-16 22:01 ` [15/83] xen-netback: remove skb in xen_netbk_alloc_page Ben Hutchings
2013-06-16 22:01 ` Ben Hutchings [this message]
2013-06-16 22:01 ` [07/83] iwlwifi: dvm: fix zero LQ CMD sending avoidance Ben Hutchings
2013-06-16 22:01 ` [17/83] xen-netback: fix sparse warning Ben Hutchings
2013-06-16 22:01 ` [04/83] cfg80211: check wdev->netdev in connection work Ben Hutchings
2013-06-16 22:01 ` [10/83] iscsi-target: fix heap buffer overflow on error Ben Hutchings
2013-06-16 22:01 ` [08/83] drm/radeon: fix card_posted check for newer asics Ben Hutchings
2013-06-16 22:01 ` [19/83] xen-netback: don't disconnect frontend when seeing oversize packet Ben Hutchings
2013-06-16 22:01 ` [09/83] xfs: kill suid/sgid through the truncate path Ben Hutchings
2013-06-16 22:01 ` [14/83] ALSA: usb-audio: avoid integer overflow in create_fixed_stream_quirk() Ben Hutchings
2013-06-16 22:01 ` [06/83] mac80211: close AP_VLAN interfaces before unregistering all Ben Hutchings
2013-06-16 22:01 ` [12/83] tg3: Add read dma workaround for 5720 Ben Hutchings
2013-06-16 22:01 ` [25/83] jfs: fix a couple races Ben Hutchings
2013-06-16 22:01 ` [28/83] ext4: lock i_mutex when truncating orphan inodes Ben Hutchings
2013-06-17 10:18 ` Luis Henriques
2013-06-16 22:01 ` [21/83] xen-netback: avoid allocating variable size array on stack Ben Hutchings
2013-06-16 22:01 ` [02/83] ata_piix: add PCI IDs for Intel BayTail Ben Hutchings
2013-06-16 22:01 ` [01/83] rapidio/tsi721: Fix interrupt mask when handling MSI Ben Hutchings
2013-06-16 22:01 ` [22/83] xen-netback: better names for thresholds Ben Hutchings
2013-06-16 22:01 ` [61/83] USB: whiteheat: fix broken port configuration Ben Hutchings
2013-06-16 22:01 ` [81/83] md/raid1: consider WRITE as successful only if at least one non-Faulty and non-rebuilding drive completed it Ben Hutchings
2013-06-16 22:01 ` [75/83] drivers/rtc/rtc-twl.c: fix missing device_init_wakeup() when booted with device tree Ben Hutchings
2013-06-16 22:01 ` [38/83] USB: revert periodic scheduling bugfix Ben Hutchings
2013-06-16 22:01 ` [39/83] USB: serial: fix Treo/Kyocera interrrupt-in urb context Ben Hutchings
2013-06-16 22:01 ` [59/83] ARM: 7742/1: topology: export cpu_topology Ben Hutchings
2013-06-16 22:01 ` [42/83] USB: ark3116: fix control-message timeout Ben Hutchings
2013-06-16 22:01 ` [47/83] ACPI / video: ignore BIOS initial backlight value for HP m4 Ben Hutchings
2013-06-16 22:01 ` [82/83] tg3: Wait for boot code to finish after power on Ben Hutchings
2013-06-16 22:01 ` [33/83] drm/gma500: Increase max resolution for mode setting Ben Hutchings
2013-06-16 22:01 ` [57/83] USB: mos7720: fix hardware flow control Ben Hutchings
2013-06-16 22:01 ` [76/83] swap: avoid read_swap_cache_async() race to deadlock while waiting on discard I/O completion Ben Hutchings
2013-06-16 22:01 ` [41/83] USB: mos7720: fix DMA to stack Ben Hutchings
2013-06-16 22:01 ` [77/83] mm: migration: add migrate_entry_wait_huge() Ben Hutchings
2013-06-16 22:01 ` [54/83] ALSA: usb-audio - Apply Logitech QuickCam Pro 9000 quirk only to audio iface Ben Hutchings
2013-06-16 22:01 ` [67/83] Bluetooth: Fix missing length checks for L2CAP signalling PDUs Ben Hutchings
2013-06-16 22:01 ` [72/83] reboot: rigrate shutdown/reboot to boot cpu Ben Hutchings
2013-06-16 22:01 ` [70/83] b43: stop format string leaking into error msgs Ben Hutchings
2013-06-16 22:01 ` [83/83] powerpc: Fix emulation of illegal instructions on PowerNV platform Ben Hutchings
2013-06-16 22:01 ` [69/83] ath9k: Use minstrel rate control by default Ben Hutchings
2013-06-16 22:01 ` [79/83] USB: pl2303: fix device initialisation at open Ben Hutchings
2013-06-16 22:01 ` [48/83] ACPI / video: ignore BIOS initial backlight value for HP Pavilion g6 Ben Hutchings
2013-06-16 22:01 ` [63/83] hwmon: (adm1021) Strengthen chip detection for ADM1021, LM84 and MAX1617 Ben Hutchings
2013-06-16 22:01 ` [32/83] USB: ftdi_sio: Quiet sparse noise about using plain integer was NULL pointer Ben Hutchings
2013-06-16 22:01 ` [50/83] drm/i915: no lvds quirk for hp t5740 Ben Hutchings
2013-06-16 22:01 ` [43/83] USB: iuu_phoenix: fix bulk-message timeout Ben Hutchings
2013-06-16 22:01 ` [71/83] CPU hotplug: provide a generic helper to disable/enable CPU hotplug Ben Hutchings
2013-06-16 22:01 ` [51/83] radeon: Fix system hang issue when using KMS with older cards Ben Hutchings
2013-06-16 22:01 ` [35/83] xhci: fix list access before init Ben Hutchings
2013-06-16 22:01 ` [31/83] USB: serial: ftdi_sio: Handle the old_termios == 0 case e.g. uart_resume_port() Ben Hutchings
2013-06-16 22:01 ` [66/83] drm/i915: prefer VBT modes for SVDO-LVDS over EDID Ben Hutchings
2013-06-16 22:01 ` [58/83] ALSA: usb-audio - Fix invalid volume resolution on Logitech HD webcam c270 Ben Hutchings
2013-06-16 22:01 ` [60/83] ARM: 7743/1: compressed/head.S: work around new binutils warning Ben Hutchings
2013-06-16 22:01 ` [55/83] drm/i915/sdvo: Use &intel_sdvo->ddc instead of intel_sdvo->i2c for DDC Ben Hutchings
2013-06-16 22:01 ` [56/83] USB: keyspan: fix bogus array index Ben Hutchings
2013-06-16 22:01 ` [73/83] audit: wait_for_auditd() should use TASK_UNINTERRUPTIBLE Ben Hutchings
2013-06-16 22:01 ` [68/83] ath9k: Disable PowerSave by default Ben Hutchings
2013-06-17 9:55 ` Luis Henriques
2013-06-17 11:55 ` Ben Hutchings
2013-06-16 22:01 ` [45/83] ACPI video: ignore BIOS backlight value for HP dm4 Ben Hutchings
2013-06-16 22:01 ` [40/83] USB: visor: fix initialisation of Treo/Kyocera devices Ben Hutchings
2013-06-16 22:01 ` [44/83] USB: mos7720: fix message timeouts Ben Hutchings
2013-06-16 22:01 ` [36/83] xhci - correct comp_mode_recovery_timer on return from hibernate Ben Hutchings
2013-06-16 22:01 ` [53/83] USB: serial: Add Option GTM681W to qcserial device table Ben Hutchings
2013-06-16 22:01 ` [64/83] drm/gma500/psb: Unpin framebuffer on crtc disable Ben Hutchings
2013-06-16 22:01 ` [34/83] xhci-mem: init list heads at the beginning of init Ben Hutchings
2013-06-16 22:01 ` [46/83] ACPI video: ignore BIOS initial backlight value for HP 1000 Ben Hutchings
2013-06-16 22:01 ` [65/83] drm/gma500/cdv: Unpin framebuffer on crtc disable Ben Hutchings
2013-06-16 22:01 ` [78/83] USB: spcp8x5: fix device initialisation at open Ben Hutchings
2013-06-16 22:01 ` [52/83] USB: Serial: cypress_M8: Enable FRWD Dongle hidcom device Ben Hutchings
2013-06-16 22:01 ` [74/83] cciss: fix broken mutex usage in ioctl Ben Hutchings
2013-06-16 22:01 ` [49/83] drm: fix a use-after-free when GPU acceleration disabled Ben Hutchings
2013-06-16 22:01 ` [62/83] USB: option: blacklist network interface on Huawei E1820 Ben Hutchings
2013-06-16 22:01 ` [37/83] usb: dwc3: gadget: free trb pool only from epnum 2 Ben Hutchings
2013-06-16 22:01 ` [80/83] x86: Fix typo in kexec register clearing Ben Hutchings
2013-06-16 22:42 ` [00/83] 3.2.47-rc1 review Ben Hutchings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=lsq.1371420097.12456539@decadent.org.uk \
--to=ben@decadent.org.uk \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=xi.wang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®