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=1796130988; b=uXj1YmUXGT0RwGn2oMoeIsUuOP4C+wiQ8DQYct11HPrLCRsyZQ/rMv/+qT30R/x2efNG JMe2J2UgC5rqPYceZJgIjWYWQJCqQ+GqTbxy+GYx53w6C5O0R6qGNIcTw4j4aAe73plWg rVI/rIYgEVfjQ33pcltvswZAM4c3zbzUOAPfyLkgX5kcu5F6pJZ5wgNjLFuzu+cGVHgEH 1sZltCYPGiPWGC3Gjwb8SARrjvo4PfN2RjWTQDrfpRm6VpJxH9X0UxU4VpbQt4BKViwV4 fCZrYk7E1DX8gcMJm82ie6sPyWz0JyRwP8vHiz2cBE0VZMYUoGgE/tHR16s2CWwv/ww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796130988; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=q80nsf1k3g3mbxvNfGRp+kyZA9f+fzgmW7/9zZwBNtU=; b=HpMOU8wBzG7yGBezVGSXWamLrRrdi67Lk5p3ZUB60ixgn3i4q2K1o/TzFUdNgs8mXVgV u54xAXzc7wloDe70PZzwORkN/5VRWFpxwkm7165Dlnrqsb21TPD92ZcrmBQXXCySeIVG/ DtYMo9Xlm+MPLrBDXGoBC7knveyvhjMmpMh+G500T+8cOlbh6oewnOlndSfsKlstylM52 ejDJaFwIR5zF6ZJmBPU/b2eFFAyTh89vy7KnNEF2CLjgnScKn+wljObBjeSmtGufiUbF0 vXebI4dZXbUxGnzinKEKniBvOWsq6cvFttyZzCGFMcTF//yW/anPnWi4cC0uT4V/vVQ== 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=bl1vLadz; 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 4BF36606A320; Tue, 1 Dec 2026 13:16:27 +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=bl1vLadz Received: by smtp.kernel.org (Postfix) with ESMTPSA id C82231F00893; Tue, 1 Dec 2026 13:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796130987; bh=q80nsf1k3g3mbxvNfGRp+kyZA9f+fzgmW7/9zZwBNtU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bl1vLadz20Nf4pNxepgSThKQh2nFLXOsnYFVRh3uOBpztR6oVqafKNoeKiQGy0Mvw pTm4XqK3LbrXgB+Cg/7m/jeAUZVxCkY4JzBSSTwxNungDPyJhdl3soWbtTH4v3bkez 7GF9jIdcriei7Gs/6o1+NUnEkN9AsGfJvw6yd2B+NhgUpq8uyEgrxvzA6JhRSFGM+T wcChqCatOzNNX4ct9u+0hX8GHZpjSQsPDRyG+yoiHHvj0t7mALeUBZO4UazdFt7Pof LkCZ9JlvB6kZqBnZPc1t40nz5mF6/1pjh3UMy2JSdfHQ7VVO3HP67zGnvFEioO0mE2 Y7rMfhmcxSTyA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 15/24] ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules 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: <20261201124753.196748-16-srinivas.kandagatla@oss.qualcomm.com> References: <20261201124753.196748-1-srinivas.kandagatla@oss.qualcomm.com> <20261201124753.196748-16-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 13:16:26 +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 2 potential issues to consider: - [Medium] ASoC: qcom: audioreach: OOB read in audioreach_speaker_protection_send_chunk() - [Medium] ASoC: qcom: audioreach: audioreach_sp_cfg_walk() rejects last sub-word param -- commit 7dba6d8b7f6739535dafe1bece50ca130cd713ea Author: Ravi Hothi ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules This commit walks the topology configuration blob of speaker protection and VI modules and sends the parameters to the DSP in 8-byte aligned APM_CMD_SET_CFG chunks. > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index 19e00563c7834..2c1ff8e65b67f 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c > @@ -1923,6 +1923,141 @@ static int audioreach_speaker_protection_vi(struc= t q6apm_graph *graph, > return rc; > } > =20 > +/* Keep each SET_CFG small; a larger single parameter is sent on its own= */ > +#define AR_SP_CFG_MAX_CHUNK_BYTES 512 > + > +static int audioreach_speaker_protection_send_chunk(struct q6apm_graph *= graph, > + const char *tag, > + const void *data, int size, > + int chunk_idx) > +{ > + int rc; > + > + struct gpr_pkt *pkt __free(kfree) =3D audioreach_alloc_apm_cmd_pkt(size= , APM_CMD_SET_CFG, 0); > + if (IS_ERR(pkt)) > + return PTR_ERR(pkt); > + > + memcpy((void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE, data, size); [ ... ] > +static int audioreach_sp_cfg_walk(const u32 *word, u32 num_words, u32 ii= d, > + u32 first, u32 *next, u8 *dst, u32 max_bytes) > +{ > + u32 pos =3D first, bytes =3D 0; > + > + while (pos < num_words) { > + u32 param_size, payload_words, avail, rec_bytes; > + > + if (word[pos] !=3D iid || num_words - pos < 4) > + return -EINVAL; > + > + param_size =3D word[pos + 2]; > + avail =3D (num_words - pos - 4) * sizeof(u32); > + if (param_size < sizeof(u32) && avail && word[pos + 4] =3D=3D iid) { > + payload_words =3D 0; > + } else { > + if (param_size > avail) > + return -EINVAL; > + payload_words =3D DIV_ROUND_UP(param_size, sizeof(u32)); > + } [Severity: Medium] Does this reject a payload-less sub-word parameter when it is the last record in the blob? When a sub-word parameter without a payload word is the final record (num_words - pos =3D=3D 4), avail is 0. Requiring avail !=3D 0 here sends execution into the else branch, where param_size > avail returns -EINVAL and fails module setup. Checking (!avail || word[pos + 4] =3D=3D iid) would allow a trailing sub-word record without a payload word. [ ... ] > +static int audioreach_speaker_protection_send_static_cfg(struct q6apm_gr= aph *graph, > + const struct audioreach_module *module, > + const char *tag) > +{ > + u32 size, num_words, pos =3D 0; > + const u32 *word; > + int total, rc =3D 0, chunk =3D 0; > + > + if (!module->data || !module->data->size) > + return 0; > + > + size =3D le32_to_cpu(module->data->size); > + word =3D (const u32 *)module->data->data; > + num_words =3D size / sizeof(u32); > + > + /* Not laid out as parameter records, so send it as the topology built = it */ > + if (size % sizeof(u32) || !num_words || word[0] !=3D module->instance_i= d) > + return audioreach_speaker_protection_send_chunk(graph, tag, word, size= , 0); [Severity: Medium] Can this fallback read past the end of module->data->data when size % sizeof(u32) is non-zero? In topology.c, audioreach_get_module_priv_data() allocates pdata->data[] for only nwords =3D array_size / sizeof(__le32) 32-bit words while leaving pdata->size set to the unrounded array_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); if (!pdata) return ERR_PTR(-ENOMEM); memcpy(pdata, ((u8 *)private->data + sz), struct_size(pdata, data, nwords)); ... } Passing the unrounded size to audioreach_speaker_protection_send_chunk() causes memcpy() to read 1 to 3 bytes past the end of the pdata slab allocation. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201124753.1967= 48-1-srinivas.kandagatla@oss.qualcomm.com?part=3D15