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=1796074896; b=cBM/hC936E1jugaFxO18FqieapAay8gEl5riCI4cVfZ4j9aN4yi6+s8yQmZCXirDFZ2m KRBniu6wgA8AuGWb7wOdPEZbTzPWlZyvRyBfFT3uSYQqLtmywscBmkgI5GHRrNgwNmg8j 38dw/XDjlEqQkqCAQuAEHTn/WX/EZZ0TxQiEPp5JVjqd8LqZGydsyN3DUPkxYBCltsH4J 9lmP69kOouGjZImsJVn5ZXmD2UAtUr1r5yGl4eG4w1islVtFcwmHkyo2gQlci5LKQ8p3C E0775T46klOguWqcLWyKGjZ33s0TGhWXbpDKGxaj6cPyDXxwgdQaVT6FlEt+eJk2eoQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796074896; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=SAUsWKqM63IztsRkwLPPKosk8UE9uqKYvCCwXp4SH/E=; b=HrJ5WaPR/TP7qnEOZj65CBso4ZiWW+zaOEI4t39BZnANpqCLjALE9PAv+Hu26tPAuF/s fdbMazWaYgQEV01CqXWwDGeRNFTvOFMrD/ttHFGsowUcZYTWuCtAF2NrWLbANngPoONzR muX2kG/G0T1O1OuXp1Aae9cCSE8QBi8i8P9F1Hcyj/7xwn99Mvf6nympaH6JHRbsBvqcm CbQIYgM2svI1lzCIhvGEObKhZV0TlOSYhAOLxqP+7wrWEyBeZ9D9J+KOUWYEkWoRMrTQ4 Ey7pGFkKXFyvtWefjyGBpy+poY5NORdnRwc2o3ayqT/IMfyqTI+6yy3IBgogmJ0fj/A== 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=VN+Jo0nC; 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 8016C606A31A; Mon, 30 Nov 2026 21:41:36 +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=VN+Jo0nC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 805D81F000C1; Mon, 30 Nov 2026 21:41:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796074895; bh=SAUsWKqM63IztsRkwLPPKosk8UE9uqKYvCCwXp4SH/E=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=VN+Jo0nCFtzTfk7RIJuVAmPjyry7dZKp/n+xxL0TDqJ25DNas6yLulX3h4nGnFCct HZMVT6FLvPe0W0fe4jH/KQiPLxHSrMDP2oYNWmyViMHMq5BlPU2qn8UTGUP6JpwI1Z K9tQDjb5qMZBNpjTduyMTiICz4Lw8TwQNhM6onkpSRkbV7oc6gilF/5lwonnUu6kHP bQHEQMagZFrMIQt0BsIe04YuFpHFWj6xRrmN0PWuD8xM1pjI6mlC+Ha42R4oQNmC/J df1bXePfaxsCdZPRAXp96nmZ1jK2Y8+GH6Wb4j2Iio227RUN8EwkqhP4WhKSf4M+qA 0IbCQO/X3Uyng== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v3 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: <20261130212258.7376-16-srinivas.kandagatla@oss.qualcomm.com> References: <20261130212258.7376-1-srinivas.kandagatla@oss.qualcomm.com> <20261130212258.7376-16-srinivas.kandagatla@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 21:41:35 +0000 X-Mailing-List: devicetree@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() fails on last sub-word param -- commit a2ac38e54e671bee64442aeeeeb762fae56eebb2 Author: Ravi Hothi ASoC: qcom: audioreach: send static cfg blobs to speaker protection modules This commit parses static topology configuration blobs for the speaker protection modules into 8-byte-padded parameter chunks and sends them to the DSP via APM_CMD_SET_CFG commands before enabling the modules. > diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/aud= ioreach.c > index 0701006278094..436d33ea568e3 100644 > --- a/sound/soc/qcom/qdsp6/audioreach.c > +++ b/sound/soc/qcom/qdsp6/audioreach.c [ ... ] > +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 audioreach_sp_cfg_walk() reject a blob whose last parameter is smaller than a word and has no payload word? When such a record is at the end of the blob (pos + 4 =3D=3D num_words), av= ail is 0, so the check enters the else branch and fails param_size > avail with -EINVAL. Checking (!avail || word[pos + 4] =3D=3D iid) would handle the trailing record as well. [ ... ] > +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 read past the end of module->data->data when size is not a multiple of sizeof(u32)? audioreach_get_module_priv_data() rounds the allocation down to full 32-bit words while keeping pdata->size unrounded: 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)); ... } When size % sizeof(u32) is non-zero (including 1 <=3D size <=3D 3 where num_words is 0), passing size to audioreach_speaker_protection_send_chunk() causes memcpy() to read 1 to 3 bytes past the end of the module->data slab buffer and send them to the DSP. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130212258.7376= -1-srinivas.kandagatla@oss.qualcomm.com?part=3D15