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 4115DC7EE31 for ; Wed, 31 May 2023 13:45:37 +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 4C78382C; Wed, 31 May 2023 15:44:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4C78382C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1685540735; bh=cCf3tJQ4w5561OUSdVs1qUeV/NIHF1MMYZMFvn77Q/0=; 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=s2L0hoExPddUX2IAPJQL2ty6KAuqZd8NGJvRnc3SEYFghtkvM91t8wKKrxHKt8TI/ Ah3osWZdWTd2ZeO1u1BcH0c838z7fn84WfV6UGGLresCe459Z4dc5bXgPUMII/22lI +1Zn9mfKgpYhDSbG1uiMi2u9WXOGWt9f/2WT1voc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2D9EBF8026A; Wed, 31 May 2023 15:43:52 +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 9108AF8026A; Wed, 31 May 2023 15:43:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 077ECF8056F; Wed, 31 May 2023 15:43:48 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 724C7F805A0 for ; Wed, 31 May 2023 15:43:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 724C7F805A0 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=XDuXJxYU 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 3E47263B52; Wed, 31 May 2023 13:43:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97C3FC433D2; Wed, 31 May 2023 13:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685540616; bh=cCf3tJQ4w5561OUSdVs1qUeV/NIHF1MMYZMFvn77Q/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDuXJxYUxiJVq3MwnzNt44U908xX/LsfHZr7szh/XaajJC9DkQA6GxfKhg6xUN9ht MGjbik/Hy0ImeRj8B26dxXaIjL/+4xzcwk8rNL/iKFKL9SR83Tc2tQ0KUDyGav+Eq6 VQwYUm6gK8GqDWemrnLJOhc7YAmbnpCcp+sQIOJiXHrGcfogjrPYzJeT+rhYJJNz8F Fj2cD2rWS4NYw08bQNVwrf3+zhJ3qfew6C719n0noq/xkpVLKRvHQ4yRxEehzcFYQa WBF2+y5QQrlgX155Eq8sUiHyJ/MGmkXA4yed1hdvIuYcEh+iSiBpY57fxqMoK7EMmf aJDukehYs1aUQ== 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 5.15 11/24] ASoC: lpass: Fix for KASAN use_after_free out of bounds Date: Wed, 31 May 2023 09:43:07 -0400 Message-Id: <20230531134320.3384102-11-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531134320.3384102-1-sashal@kernel.org> References: <20230531134320.3384102-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Message-ID-Hash: 34LISLYWSEACJIDQUNR5RGWZSO3FANS6 X-Message-ID-Hash: 34LISLYWSEACJIDQUNR5RGWZSO3FANS6 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 35d148e60c334..4377e91733b87 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -743,6 +743,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: @@ -769,6 +771,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