Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp894621imu; Fri, 11 Jan 2019 10:58:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN6sMDtmIbQ/zq3H2XUNN+7Ibuc0QoYWCT6o/wm6U3rtIUhel/irbbXhDd5cTH7/dzqPpB2s X-Received: by 2002:a17:902:6b09:: with SMTP id o9mr15714742plk.208.1547233087314; Fri, 11 Jan 2019 10:58:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547233087; cv=none; d=google.com; s=arc-20160816; b=e3DC8o4WED2S3VEflU/eYhq0LbJ3utCFakEnugUqoFmFonD7CW1paSmIqZYPDnEsfu NAnKJrA3qz4mKnxudPFepdmlqpeQuyibROcJsWH1c0IPrygmGppSj8dBezkKq2ZOCubg Ro9fCRTxYDp4irVCRtSmYslsMrn+trPfKtBLhIaORKroYiX9OsK+HwLoHl86vniljnn8 DRzMNF7ka0oUe2y0shwZhZZUrgW1lHDPk8hIEVcAm9lRk09SVKNc0fp9XBDE/ZhAPW7b CsNbuaNQhPXzkE6LWuya5Rmik+aWgMXS9ZzexL3AOnYNTSSPEDf2aWnONtAZ4fBud1P/ jV8A== 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=eA14a6JvAffzrvzaI35pZkj9zx+NFEVqyYdGn67PkyI=; b=Tjfiy5qBgivK5Bt2z2MdydwbSNRlBo7zV9tHiJA2Eu5zHTimR5fulCg6F3CdDlFeWZ dn5Z525GW4gL7qyNN+hGqGOmwRcvUhTW8a53ar/ntc9759p23gVRwgwS6BrmxoUAJURC VAsxhjFJ1L3iihdQ90CapR6cPwJGBZLEIsM7ZrZLkCu/h9zAVe1Btp9UCMVkbXwjxDsK dLGjcWO/QfAGL6/G9PcqdejBUksob9uUKPxjfTQJcfxKKTnfOOHZjNAlF3L6Kmf3Dfil d01zeVT+atpGKaflgZ/juXDQ4FdZMbrr35SnvguDqRI6zn6B+jn+QWw+gfPGpX2sTAq4 WGFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="u8j/+MPj"; 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 j22si72138899pgj.244.2019.01.11.10.57.51; Fri, 11 Jan 2019 10:58:07 -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="u8j/+MPj"; 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 S1732722AbfAKOVe (ORCPT + 99 others); Fri, 11 Jan 2019 09:21:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:36544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732307AbfAKOTa (ORCPT ); Fri, 11 Jan 2019 09:19:30 -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 BF37D2177B; Fri, 11 Jan 2019 14:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547216370; bh=evGUiSd3/p5Xn7ZWXsumvfYNYN1pN+iNvwLtvg26v2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8j/+MPjDxRVLfce7GwWXwe/nCQFS9DAtzUqLNO2iCiB25CGHCJw+3smr+oLAWPgw VVsFa3wAKkoQAQBxdmFknbdINQXBQFtDO7jQfphy36UQz2f0X+ediXAEb8LZ7a6dIO zBUrfdJAlNNpucyaUvOT9maocYknyd4nmJEDKPBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.4 74/88] ALSA: usb-audio: Avoid access before bLength check in build_audio_procunit() Date: Fri, 11 Jan 2019 15:08:43 +0100 Message-Id: <20190111131058.387464958@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131045.137499039@linuxfoundation.org> References: <20190111131045.137499039@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.4-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 @@ -1816,7 +1816,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; @@ -1831,7 +1831,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;