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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40024C7EE2F for ; Wed, 31 May 2023 13:44:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2BB7A828; Wed, 31 May 2023 15:43:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2BB7A828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685540658; bh=RCHWS+o1hDInbDlH2a1xOIWLzTL1qLvXYRuq+jY8uqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=JfLGBl+M/fltOi5EsYL7JJJCnwmWRmnshrdrwyKUBrD0DbgwS8cfFoeBVkukdMXCI NvQs3M9m+WELI9sWKc8vV1Xww4IUg3saZ11ixzVByHt6LC75K+AKBL8/t8xkpG4uOE d4rirdfE2TgW6bzb2EW1wqIH9NYy15X0jieC5VKE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 24B4CF80557; Wed, 31 May 2023 15:42:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CD5A3F80557; Wed, 31 May 2023 15:42:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A5C35F80557; Wed, 31 May 2023 15:42:29 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C48C0F80528 for ; Wed, 31 May 2023 15:42:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C48C0F80528 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=trr04afc 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 ADE6063B5A; Wed, 31 May 2023 13:42:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A977C4339C; Wed, 31 May 2023 13:42:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685540546; bh=RCHWS+o1hDInbDlH2a1xOIWLzTL1qLvXYRuq+jY8uqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=trr04afcP5u6M1N2bvuo8uB1Ao5YdLX3TJIDzydzTkA+AY7z8ZSvWI+CTmyD1lNXj 9NaMCxvMtHxzogVJS302JzCHeisiyPbSo0skwb/C7Sq/k5ZyHGgvrI8s0Kuofeymyz +9FjvZnqGflVUltM96zk11wTZ86sJt2XP26s8/wdYpEz0Wf0gORZsH49tt7AkoDEBA N33e4c6qWup8R/Dh1WDoka04OTjsrspWSKNxueW3hck2Ioq7vo6w7RfnBRWxAtthbP pe/VoylsXQx1lpDPwPz5gTa9EhmNxAbDLrerJBUTWZQpOhxxMu4MKlvQm5/sxq8clG QmQaj+Y9q5HHA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ravulapati Vishnu Vardhan Rao , Sasha Levin , srinivas.kandagatla@linaro.org, bgoswami@quicinc.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 6.1 14/33] ASoC: lpass: Fix for KASAN use_after_free out of bounds Date: Wed, 31 May 2023 09:41:40 -0400 Message-Id: <20230531134159.3383703-14-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531134159.3383703-1-sashal@kernel.org> References: <20230531134159.3383703-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Message-ID-Hash: P4LMW5TUVBOAARR7ADWLEWHSQWYCULJH X-Message-ID-Hash: P4LMW5TUVBOAARR7ADWLEWHSQWYCULJH X-MailFrom: sashal@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Ravulapati Vishnu Vardhan Rao [ Upstream commit 75e5fab7db0cecb6e16b22c34608f0b40a4c7cd1 ] When we run syzkaller we get below Out of Bounds error. "KASAN: slab-out-of-bounds Read in regcache_flat_read" Below is the backtrace of the issue: BUG: KASAN: slab-out-of-bounds in regcache_flat_read+0x10c/0x110 Read of size 4 at addr ffffff8088fbf714 by task syz-executor.4/14144 CPU: 6 PID: 14144 Comm: syz-executor.4 Tainted: G W Hardware name: Qualcomm Technologies, Inc. sc7280 CRD platform (rev5+) (DT) Call trace: dump_backtrace+0x0/0x4ec show_stack+0x34/0x50 dump_stack_lvl+0xdc/0x11c print_address_description+0x30/0x2d8 kasan_report+0x178/0x1e4 __asan_report_load4_noabort+0x44/0x50 regcache_flat_read+0x10c/0x110 regcache_read+0xf8/0x5a0 _regmap_read+0x45c/0x86c _regmap_update_bits+0x128/0x290 regmap_update_bits_base+0xc0/0x15c snd_soc_component_update_bits+0xa8/0x22c snd_soc_component_write_field+0x68/0xd4 tx_macro_put_dec_enum+0x1d0/0x268 snd_ctl_elem_write+0x288/0x474 By Error checking and checking valid values issue gets rectifies. Signed-off-by: Ravulapati Vishnu Vardhan Rao --- sound/soc/codecs/lpass-tx-macro.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index d1d9d8d2df2d2..9f59518005a5f 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -745,6 +745,8 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, struct tx_macro *tx = snd_soc_component_get_drvdata(component); val = ucontrol->value.enumerated.item[0]; + if (val >= e->items) + return -EINVAL; switch (e->reg) { case CDC_TX_INP_MUX_ADC_MUX0_CFG0: @@ -771,6 +773,9 @@ static int tx_macro_put_dec_enum(struct snd_kcontrol *kcontrol, case CDC_TX_INP_MUX_ADC_MUX7_CFG0: mic_sel_reg = CDC_TX7_TX_PATH_CFG0; break; + default: + dev_err(component->dev, "Error in configuration!!\n"); + return -EINVAL; } if (val != 0) { -- 2.39.2