Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp985906imu; Fri, 11 Jan 2019 12:44:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN68DJUhFVv8m+jmxDKEV6yXvUjHXKSa7bf6/E7znDjvPF2jPb/18LEav4UFuzKe90WSoUOl X-Received: by 2002:a62:442:: with SMTP id 63mr15736341pfe.156.1547239488945; Fri, 11 Jan 2019 12:44:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547239488; cv=none; d=google.com; s=arc-20160816; b=jlQ5E4v/N1bV7J9g9+rTARzcp/zFIdTlq48/nypgb5HLz38+OOk6+CJmbgT01VJuue LVfDVcBAA1oIzrhDxWeyNYmRgchx1BQyn4VgRdh3zqhvOvxOLkBkIHIACk2jvEPSYLs5 CLORNQn6Xj2SFEhfxTmYiZlrZTSif1D6S47fmZ+xrcUVm8fS5DUK+sawgSmpkVQcInui AgsHCbw5FyZDnQ2WMzN5dtkhev7aCtjzB/P9NIFHL+aUoN4x/J8bSvzsGWOS6KgSgK1p OZJatCgdAj1g/ENqJ+WHywwLLvcLeRJTVCKIj95xRVb+AoOb2sNR3WF0TrNWQvE3vIY8 m98w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ILCupOGJRMDDBZbCbtdddRzONAknldHTfGcYP4MuTPc=; b=fVZZocMAjQI5i7HG0ZO3OUFz6HPq4oZzUT1GlEe7GaBQ1yWq737YxcjFWGRls8bHKs Cn2euBckFltqF8ZOEaMPUCZhujpZ+rWMF98s5TkJJfyntLyPtRhZ8JyBqy6GZ59PJGw8 mm987ifMRJZekcjo985Ac2jq8Uhh6e/4YKR5wK9W75FA5cs5PVsRy4X/Hphmy3ypfpfg BxRTl/iFcBMFAP6aJjezd8tGPlkXy0yb+/HsoSnoVx/6FroNJs+5lKUyceqbsoQ/tX4n JrpFwJDCMSVLLaGDtfG6WAHKaw0yn1D5AVFAG6SmEvXpmxHFI9lQjVtr/Jr7Y8WQlrGs sldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ziDbxwhL; 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 m3si20202115pld.331.2019.01.11.12.44.33; Fri, 11 Jan 2019 12:44:48 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ziDbxwhL; 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 S2391352AbfAKOmI (ORCPT + 99 others); Fri, 11 Jan 2019 09:42:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:34880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388066AbfAKOmG (ORCPT ); Fri, 11 Jan 2019 09:42:06 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 130012133F; Fri, 11 Jan 2019 14:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217725; bh=nqLMuK+irL0+qVdTAtDVyB9bLNryJDDmoyv9EpEuYwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ziDbxwhLYpr1ILH0Le+zSR/+h/skGDsagAuyR+84Rkw4wQEB4yHkPyLou/+UELAAq uzI7taqLFALJANhvajYj2/4X7dGQt/EYRJ4kvs04v22yPeMdWUYTno0FUuDkLBGjz3 AR/e6cIoauBpUAq+k8HGIo8NY0gVrcAUlxP9kfUo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.20 19/65] ALSA: usb-audio: Avoid access before bLength check in build_audio_procunit() Date: Fri, 11 Jan 2019 15:15:05 +0100 Message-Id: <20190111131059.079395634@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit f4351a199cc120ff9d59e06d02e8657d08e6cc46 upstream. The parser for the processing unit reads bNrInPins field before the bLength sanity check, which may lead to an out-of-bound access when a malformed descriptor is given. Fix it by assignment after the bLength check. Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/mixer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -2314,7 +2314,7 @@ static int build_audio_procunit(struct m char *name) { struct uac_processing_unit_descriptor *desc = raw_desc; - int num_ins = desc->bNrInPins; + int num_ins; struct usb_mixer_elem_info *cval; struct snd_kcontrol *kctl; int i, err, nameid, type, len; @@ -2329,7 +2329,13 @@ static int build_audio_procunit(struct m 0, NULL, default_value_info }; - if (desc->bLength < 13 || desc->bLength < 13 + num_ins || + if (desc->bLength < 13) { + usb_audio_err(state->chip, "invalid %s descriptor (id %d)\n", name, unitid); + return -EINVAL; + } + + num_ins = desc->bNrInPins; + if (desc->bLength < 13 + num_ins || desc->bLength < num_ins + uac_processing_unit_bControlSize(desc, state->mixer->protocol)) { usb_audio_err(state->chip, "invalid %s descriptor (id %d)\n", name, unitid); return -EINVAL;