From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796392588; b=hvZV/ulQ6RfTdFP9A27Rsg41Lf/Wcov7y1ng1F5ex9GShvyOg5jdqZXvsxOzPj0PTaQm C/qJBfvSfFb1dzV6wpAz91X9YootYwlz1XIghrgw6O/2e+elLOPcuZxpb58Rwa7ylA4pB zEDOvusGI32m0CF1oxu0YubGd+k9QD9zk9DYk8zmM9csG4YZFB9BAv2KV+tBK+8HMdriv K6RJYv6JGj+dQYtq2x3JES3cVbMzV1qeU0NZOF02edlBJt8Vuqt99CPMZaSw0YAu6/NK4 ED8i4kz+c9lloFacvynxuT4ja6zycT6Ubehvmq0le3O0Ibn2jHY9pU5xGlTosYD9Dmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796392588; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=l4SoKpP8Fl/o9eVZjJFTdaV81EbbzJhdm5egQ35R9U8=; b=GoPjGVwYZAHnuln4/U5KVxQzJQTZaGEJC2E5X14O36eKDAEa9sWBpowFQQexANZjRFVN MDXOiH9991LcGtWs1CEZxwLpYosg+6ba5Fk3sQuFSehPIYPZGVt9316xhlavOPPHDl/d9 dP6+SrKUbPVCoCz7OIiS0DJdyo6nofs7qLZX0QVhanI2URKxmFBawtTx5BQkvKLdA4Mq5 oSHzvFVv3kbbplz8985Kfn0wEwFp7CzOefhhMZeQcWBfWYoSTg0uwIxrxqVkBGaBfs3Pn T1f0vd0QNKOgV2NJ9jR7wCCv/d4FXsmEt0cmIle/MEZB4n/JPvshd2wTR2onTRAur8g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DeKAtceW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0505606A336; Fri, 4 Dec 2026 13:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DeKAtceW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14E991F0093A; Fri, 4 Dec 2026 13:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796392588; bh=l4SoKpP8Fl/o9eVZjJFTdaV81EbbzJhdm5egQ35R9U8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=DeKAtceWDKNua6cmLEankZA4x8VzH8fIsU3mFIqHTfw9TQuYHOCaVl+BfFHZ9zJlu EK/iPSifnTj6YDn0xYrl1wq5aQ7wmT6xIZzkikAroJVlGyDWPUsuR5LM/f3uG/Chs+ o62W8uqWFHpssL/b9peuidotq1+0svLv1fxGSZRKnjhUyFpNdx6furrjtTJfkHJWMw uTfQde66nHZ+Mw0umcaWURm0BfVIjhQu//l9B1PjueAHzgBm1q81njOFXK59ZeYr+M fWZX/9LBYlaXw/FRE3Ncd87X9qudSXN3thqOsu/4MGT014u/VrgEO6/xYdORbDVh0W +JCHdd+yeN7uA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 17/24] ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format Reply-To: sashiko-reviews@lists.linux.dev To: "Srinivas Kandagatla" Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204113101.1141644-18-srinivas.kandagatla@oss.qualcomm.com> References: <20261204113101.1141644-1-srinivas.kandagatla@oss.qualcomm.com> <20261204113101.1141644-18-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 13:56:27 +0000 X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] ASoC: qcom: TOCTOU race on sp_operation_mode across SP and VI modules - [Medium] ASoC: qcom: heap OOB read in audioreach_speaker_protection_send_static_cfg() - [Low] ASoC: qcom: dead sp_vi_cfg overrides in audioreach_set_media_format() -- commit 2e9d1aaa9d032e965bfa3fbbc815b46ec62787a1 Author: Srinivas Kandagatla ASoC: qcom: audioreach: pin SPEAKER_PROTECTION_VI media format This commit overrides the sample rate and bit width to 8 kHz and 32 bits in audioreach_set_media_format() for MODULE_ID_SPEAKER_PROTECTION_VI and for any MODULE_ID_CODEC_DMA_SOURCE in a subgraph containing it. > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index fd803d6ceccd0..d1f6cd2b66354 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c > @@ -2064,12 +2064,41 @@ static int audioreach_speaker_protection_vi_stati= c_cfg(struct q6apm_graph *graph > return audioreach_speaker_protection_send_static_cfg(graph, module, "VI= "); > } [Severity: Medium] Can audioreach_speaker_protection_send_static_cfg() read past the end of module->data when size is not a multiple of 4? audioreach_get_module_priv_data() truncates the allocation to whole __le32 words while keeping the unrounded byte count in pdata->size: sound/soc/qcom/qdsp6/topology.c:audioreach_get_module_priv_data() { ... nwords =3D array_size / sizeof(__le32); ... pdata =3D kzalloc_flex(*pdata, data, nwords); ... } When a speaker protection topology blob has a non-4-byte-aligned size, audioreach_speaker_protection_send_static_cfg() hits its size % sizeof(u32) fallback and passes the unrounded size to audioreach_speaker_protection_send_chunk(), where memcpy() reads 1 to 3 bytes past the allocated slab object and sends them to the DSP. [ ... ] > int audioreach_set_media_format(struct q6apm_graph *graph, > const struct audioreach_module *module, > const struct audioreach_module_config *cfg) > { > + struct audioreach_module_config sp_vi_cfg; > int rc; > =20 > + /* The VI module and its codec DMA source always run at 8 kHz, S32_LE */ > + if (module->module_id =3D=3D MODULE_ID_SPEAKER_PROTECTION_VI || > + (module->module_id =3D=3D MODULE_ID_CODEC_DMA_SOURCE && > + audioreach_sg_contains_sp_vi(module->container ? > + module->container->sub_graph : NULL))) { > + sp_vi_cfg =3D *cfg; > + sp_vi_cfg.sample_rate =3D 8000; > + sp_vi_cfg.bit_width =3D 32; > + sp_vi_cfg.bits_per_sample =3D 32; > + cfg =3D &sp_vi_cfg; > + } [Severity: Low] Are the MODULE_ID_SPEAKER_PROTECTION_VI check and the bits_per_sample assignment needed here? audioreach_speaker_protection_vi() only reads num_channels and channel_map[] from cfg, ignoring sample_rate, bit_width, and bits_per_sample, so copying *cfg for the VI module has no effect. audioreach_codec_dma_set_media_format() also never reads bits_per_sample (nothing in sound/soc/qcom/qdsp6/ does). > =20 > switch (module->module_id) { [Severity: Medium] Can the speaker protection and VI modules in the same graph be programmed with mismatched sp_operation_mode values? q6apm_graph_media_format_pcm() calls audioreach_set_media_format() for each module in sequence without snapshotting sp_operation_mode, and the SP and VI handlers each perform an independent READ_ONCE() across sleeping DSP IPC calls: CPU0 CPU1 q6apm_graph_media_format_pcm() audioreach_set_media_format(SP) audioreach_speaker_protection() READ_ONCE(sp_operation_mode) /* sees Normal, sends IPC */ audioreach_trigger_sp_calibration() /* switches to Calibration */ audioreach_set_media_format(VI) audioreach_speaker_protection_vi() READ_ONCE(sp_operation_mode) <-- sees Calibration If calibration is triggered (or the calibration watchdog fires) during this window, the coupled SP and VI modules end up in opposite modes, breaking speaker protection or calibration. Snapshotting sp_operation_mode once per graph prepare pass would keep both modules consistent. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204113101.1141= 644-1-srinivas.kandagatla@oss.qualcomm.com?part=3D17