From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98BF2C3A5A8 for ; Wed, 4 Sep 2019 18:02:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 745BA22CF5 for ; Wed, 4 Sep 2019 18:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620178; bh=loe82XiiFqDncGdpxuAyI0smABOQem9qmcY9siwJHrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=C/BVV7zWSizP2thYlNyRI9czlnXtBXkTnwOKx/IzzfzAsKumgIsQt8joy/+EvA4kt IYaYU2D0gpK/ybCJKoPFvEoyAFAHwbx3Hrjo4NvMi75guNziYljv75V5Cm6jqRDVQF sNVsdtoE2L/nFC+6NJ28EpZJataq0d146PJrxF6E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388851AbfIDSC5 (ORCPT ); Wed, 4 Sep 2019 14:02:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:43104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388825AbfIDSCz (ORCPT ); Wed, 4 Sep 2019 14:02:55 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 EA75722CF5; Wed, 4 Sep 2019 18:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620174; bh=loe82XiiFqDncGdpxuAyI0smABOQem9qmcY9siwJHrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOhOkaefseWnXjDZ7MRCDAupie4vFxbPW1+VY6VlB7Ja3m7SE+cMuovB3qgja22MP usCEvZPF3sPs0jQYkVD48sW0aHwdxrB7z/I/WmVjTiGuEqm83VeifCk0kMNOUDC2u9 4soCr02SWxRX4p6EG66T02P8u3IFMkFhhpKz6/Ic= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hui Peng , Mathias Payer , Takashi Iwai Subject: [PATCH 4.14 18/57] ALSA: usb-audio: Fix an OOB bug in parse_audio_mixer_unit Date: Wed, 4 Sep 2019 19:53:46 +0200 Message-Id: <20190904175303.725620365@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175301.777414715@linuxfoundation.org> References: <20190904175301.777414715@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Hui Peng commit daac07156b330b18eb5071aec4b3ddca1c377f2c upstream. The `uac_mixer_unit_descriptor` shown as below is read from the device side. In `parse_audio_mixer_unit`, `baSourceID` field is accessed from index 0 to `bNrInPins` - 1, the current implementation assumes that descriptor is always valid (the length of descriptor is no shorter than 5 + `bNrInPins`). If a descriptor read from the device side is invalid, it may trigger out-of-bound memory access. ``` struct uac_mixer_unit_descriptor { __u8 bLength; __u8 bDescriptorType; __u8 bDescriptorSubtype; __u8 bUnitID; __u8 bNrInPins; __u8 baSourceID[]; } ``` This patch fixes the bug by add a sanity check on the length of the descriptor. Reported-by: Hui Peng Reported-by: Mathias Payer Cc: Signed-off-by: Hui Peng Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/mixer.c | 1 + 1 file changed, 1 insertion(+) --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1719,6 +1719,7 @@ static int parse_audio_mixer_unit(struct int pin, ich, err; if (desc->bLength < 11 || !(input_pins = desc->bNrInPins) || + desc->bLength < sizeof(*desc) + desc->bNrInPins || !(num_outs = uac_mixer_unit_bNrChannels(desc))) { usb_audio_err(state->chip, "invalid MIXER UNIT descriptor %d\n",