Received: by 10.223.185.116 with SMTP id b49csp823076wrg; Sat, 10 Feb 2018 21:13:32 -0800 (PST) X-Google-Smtp-Source: AH8x227yYiTidwpAP/A4SLkZuZhYNfkecJGheyoDzM+zjweyRCawUatqBay8fudWJXRgjhshEeM8 X-Received: by 2002:a17:902:b082:: with SMTP id p2-v6mr7279761plr.314.1518326012835; Sat, 10 Feb 2018 21:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326012; cv=none; d=google.com; s=arc-20160816; b=nsibcFl3sMpp4FnVbsIzABQHlRi4fa0mVmnK2qI5ropFoa9NvAZEWSCyHsbzTDI910 0jm+GPTJR7GVbdsAcWwZ7L8z5JbZImV8Xa51rTXpaXi1nd16XT20UXBxHhvi0G/GD8ou 2TggsFs0pKyRxKTQFM+qDE2FKepP2yKdNlLKot4IyJXiKb4hToUuQW9veTC8eQColmhK 9csQU5zvIyMchasfSxVhhsw6ME0b9I7s9YH+H/6hc3hOe3Q9sZeGAvW+OU2pLDK7I/0k BIAJbnC34e0Xd3n/2uAZ5bUTwvdgX6CIgUScINMzEjCixkCinyUPHMzgYzy7nbGMLG/Y THKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=LSAVzs7QWc1tOWUkIkrVPrk/joGxHI3gA6dkvNj2kKE=; b=g+jKrtl7bgnP5umtWmH6Y15wZqAHnnODfSvittg50vGtr0uvkUFyvVKd6SW/0WT1QO SueUcjsuG4mQBRX2I3ShD6Fa/TnDrPM7JPEd2MVGDAtRt5GSwk6aenydJaJZcK8KemjS RvY1m/dBYfmmspcwXc7otdEZAz9/nL/46/l9NWMit2ZE6rxkm6Bk11K+iCIEiyNBDmxF WjV/Mw64Zr8mYpyQEGMXz9cBRJOsZWfuioymLpP9JaQY7fCRweOmk5WafMpzAG3ar6hq JBGKhuqbKIaE0ABKxbgQClFXwQHElmxmUIptKU244ckThqzceHBrrRMUW+OC26947AFq gfgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u67si3585920pgc.762.2018.02.10.21.13.19; Sat, 10 Feb 2018 21:13:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932081AbeBKFLJ (ORCPT + 99 others); Sun, 11 Feb 2018 00:11:09 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41434 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbeBKEdm (ORCPT ); Sat, 10 Feb 2018 23:33:42 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekjKd-0002hK-Rt; Sun, 11 Feb 2018 04:33:40 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKY-0004Vr-Fb; Sun, 11 Feb 2018 04:33:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Takashi Iwai" , "Andrey Konovalov" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 55/79] ALSA: usb-audio: Add sanity checks to FE parser In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit d937cd6790a2bef2d07b500487646bd794c039bb upstream. When the usb-audio descriptor contains the malformed feature unit description with a too short length, the driver may access out-of-bounds. Add a sanity check of the header size at the beginning of parse_audio_feature_unit(). Fixes: 23caaf19b11e ("ALSA: usb-mixer: Add support for Audio Class v2.0") Reported-by: Andrey Konovalov Signed-off-by: Takashi Iwai [bwh: Backported to 3.2: use snd_printk() for logging] Signed-off-by: Ben Hutchings --- sound/usb/mixer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1255,6 +1255,12 @@ static int parse_audio_feature_unit(stru __u8 *bmaControls; if (state->mixer->protocol == UAC_VERSION_1) { + if (hdr->bLength < 7) { + snd_printk(KERN_ERR + "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", + unitid); + return -EINVAL; + } csize = hdr->bControlSize; if (!csize) { snd_printdd(KERN_ERR "usbaudio: unit %u: " @@ -1271,6 +1277,12 @@ static int parse_audio_feature_unit(stru } } else { struct uac2_feature_unit_descriptor *ftr = _ftr; + if (hdr->bLength < 6) { + snd_printk(KERN_ERR + "usbaudio: unit %u: invalid UAC_FEATURE_UNIT descriptor\n", + unitid); + return -EINVAL; + } csize = 4; channels = (hdr->bLength - 6) / 4 - 1; bmaControls = ftr->bmaControls;