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=-11.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED 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 5670AC43387 for ; Thu, 10 Jan 2019 19:48:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2427120879 for ; Thu, 10 Jan 2019 19:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547149724; bh=iMbn8wj++J/V0PCT0kHlQUVuSAJq8Mxl0Z/6fY/Bg34=; h=Subject:To:Cc:From:Date:List-ID:From; b=uKhb6tgUoe/zzETGVfeHsPVF9/GJiSuT3xksUsnqnPUh/ZQHhNBb7deqeeY1YHvWL 7rPg42i3kWutYoUqkRBlVwbDY/b6aWifYeKjoQ5OYLlkzESyUAzophoyuhbZaA0P19 ysHMbHbX7UTLlNXzTlzPEYpvrThInfTamvPPaKZw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728391AbfAJTsn (ORCPT ); Thu, 10 Jan 2019 14:48:43 -0500 Received: from wnew4-smtp.messagingengine.com ([64.147.123.18]:46501 "EHLO wnew4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728073AbfAJTsn (ORCPT ); Thu, 10 Jan 2019 14:48:43 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id D3A6F1688; Thu, 10 Jan 2019 14:48:42 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 10 Jan 2019 14:48:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Y/Flwt qfzuQwNuILE8yjQmr5JL4UiXPsVTDUxBmPVeg=; b=coHaUCxrKxq8iuXTh4H1PF +gijoWEAgCyOCMcvmbObCxk46obLAtMnElml2nXzARbW3/GTzG/L5aOqa/L4cU5U kVy0B7qQ8cHa98IzAOyomDmIuLfDs0ogELN9S236XPxYogYMvzT+A+fvNL0SCzqZ 4Zf7OsiEEFwjX+LMFAzIu5ePGnVVkoCquISF1SL5Hm+fZ5FyQqjQ7EbrI6kNhRD/ 4maf9HSBKv6VtlFhexKPE0vyDlmftJkMcvsXZ4+FUVxDpRrvdvGSvf/m+TqQP7BR 4+gJG3NS0zQIWUR5o54R8LIInznL/gOqSKleUly2IHWYXFyuJysNZc61V3gaZ5OQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrfeefgddufedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecuogfuphgrmhfkphculdeftddtmdenucfjughrpefuvffhfffkgggtgfesthekre dttddtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdr ohhrgheqnecukfhppeekfedrkeeirdekledruddtjeenucfrrghrrghmpehmrghilhhfrh homhepghhrvghgsehkrhhorghhrdgtohhmnecuvehluhhsthgvrhfuihiivgepud X-ME-Proxy: Received: from localhost (5356596b.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id C5DD1102F1; Thu, 10 Jan 2019 14:48:41 -0500 (EST) Subject: FAILED: patch "[PATCH] ALSA: usb-audio: Check mixer unit descriptors more strictly" failed to apply to 4.9-stable tree To: tiwai@suse.de, stable@vger.kernel.org Cc: From: Date: Thu, 10 Jan 2019 20:48:40 +0100 Message-ID: <154714972011632@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 4.9-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 0bfe5e434e6665b3590575ec3c5e4f86a1ce51c9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 19 Dec 2018 14:04:47 +0100 Subject: [PATCH] ALSA: usb-audio: Check mixer unit descriptors more strictly We've had some sanity checks of the mixer unit descriptors but they are too loose and some corner cases are overlooked. Add more strict checks in uac_mixer_unit_get_channels() for avoiding possible OOB accesses by malformed descriptors. This also changes the semantics of uac_mixer_unit_get_channels() slightly. Now it returns zero for the cases where the descriptor lacks of bmControls instead of -EINVAL. Then the caller side skips the mixer creation for such unit while it keeps parsing it. This corresponds to the case like Maya44. Cc: Signed-off-by: Takashi Iwai diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 0131de348cf6..dfd918891e69 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -753,8 +753,9 @@ static int uac_mixer_unit_get_channels(struct mixer_build *state, struct uac_mixer_unit_descriptor *desc) { int mu_channels; + void *c; - if (desc->bLength < 11) + if (desc->bLength < sizeof(*desc)) return -EINVAL; if (!desc->bNrInPins) return -EINVAL; @@ -763,6 +764,8 @@ static int uac_mixer_unit_get_channels(struct mixer_build *state, case UAC_VERSION_1: case UAC_VERSION_2: default: + if (desc->bLength < sizeof(*desc) + desc->bNrInPins + 1) + return 0; /* no bmControls -> skip */ mu_channels = uac_mixer_unit_bNrChannels(desc); break; case UAC_VERSION_3: @@ -772,7 +775,11 @@ static int uac_mixer_unit_get_channels(struct mixer_build *state, } if (!mu_channels) - return -EINVAL; + return 0; + + c = uac_mixer_unit_bmControls(desc, state->mixer->protocol); + if (c - (void *)desc + (mu_channels - 1) / 8 >= desc->bLength) + return 0; /* no bmControls -> skip */ return mu_channels; } @@ -944,7 +951,7 @@ static int check_input_term(struct mixer_build *state, int id, struct uac_mixer_unit_descriptor *d = p1; err = uac_mixer_unit_get_channels(state, d); - if (err < 0) + if (err <= 0) return err; term->channels = err; @@ -2118,7 +2125,7 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, if (err < 0) continue; /* no bmControls field (e.g. Maya44) -> ignore */ - if (desc->bLength <= 10 + input_pins) + if (!num_outs) continue; err = check_input_term(state, desc->baSourceID[pin], &iterm); if (err < 0)