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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00F74ECAAD3 for ; Wed, 14 Sep 2022 09:15:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231533AbiINJPs (ORCPT ); Wed, 14 Sep 2022 05:15:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231559AbiINJNo (ORCPT ); Wed, 14 Sep 2022 05:13:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59D697C741; Wed, 14 Sep 2022 02:06:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B126619FA; Wed, 14 Sep 2022 09:05:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69EEBC4347C; Wed, 14 Sep 2022 09:05:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663146328; bh=mOq3bZhWB9k345JibXBrxgU7rRRFOigtopbDGHTtbz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHPsPTEsQxHgUFHsE+enS8dB8WXSerpXyevGxo1bZE0FzULxEFPvCk6f1TndG65pp 41xzpoFYKvxTbVxVOzT5HC7SlWp2bQuxY7PB/nXeI6CTVVH84pNRl0SCFoVderlVkG l9EUP/MPlTsMD6Tpz4Ffe2k4nMstOJ3wJxCiD0zXHGp4Y/69NBa2c+C1DpI2Rmmt9A YyKz+rrTkVzGEja2bVousL9Oqw7lHnWAWPaFoxOisy0UNB+4ynSGH7gXQ/Rw4lf3eJ qae9CAc8uZ/Ocwiw6KOm0xj872KdXwuh0EYe8NEpFUOkBfi7eUSpxh0HMeObt8du0e X+f2PI0hPxgDg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dongxiang Ke , Takashi Iwai , Sasha Levin , perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 4.14 4/8] ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() Date: Wed, 14 Sep 2022 05:05:08 -0400 Message-Id: <20220914090514.471614-4-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220914090514.471614-1-sashal@kernel.org> References: <20220914090514.471614-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongxiang Ke [ Upstream commit e53f47f6c1a56d2af728909f1cb894da6b43d9bf ] There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and the number of it's interfaces less than 4, an out-of-bounds read bug occurs when parsing the interface descriptor for this device. Fix this by checking the number of interfaces. Signed-off-by: Dongxiang Ke Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/usb/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 7b86bf38f10e7..133a66a7f90e4 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -502,7 +502,7 @@ int snd_usb_parse_audio_interface(struct snd_usb_audio *chip, int iface_no) * Dallas DS4201 workaround: It presents 5 altsettings, but the last * one misses syncpipe, and does not produce any sound. */ - if (chip->usb_id == USB_ID(0x04fa, 0x4201)) + if (chip->usb_id == USB_ID(0x04fa, 0x4201) && num >= 4) num = 4; for (i = 0; i < num; i++) { -- 2.35.1