From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: dmaengine@vger.kernel.org, Frank.Li@kernel.org, vkoul@kernel.org
Subject: Re: [PATCHv2] dma: bestcomm: gen_bd: split struct bcom_psc_params from array definition
Date: Sat, 30 May 2026 02:19:06 +0000 [thread overview]
Message-ID: <20260530021906.99C2B1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260530012554.68605-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Inadequate or missing bounds checking on `psc_num` can lead to out-of-bounds array access in `bcom_psc_params`.
--
commit c24864efcf21b2526be68d727e70076f6cee258c
Author: Rosen Penev <rosenp@gmail.com>
dma: bestcomm: gen_bd: split struct bcom_psc_params from array definition
This commit splits the bcom_psc_params struct definition from its array
declaration to resolve kernel-doc parser warnings. It also adds missing
members and marks the lookup table as const so it can be moved to read
only memory.
> diff --git a/drivers/dma/bestcomm/gen_bd.c b/drivers/dma/bestcomm/gen_bd.c
> index 8a24a5cbc2633..61b5746e1a972 100644
> --- a/drivers/dma/bestcomm/gen_bd.c
> +++ b/drivers/dma/bestcomm/gen_bd.c
> @@ -254,17 +254,23 @@ EXPORT_SYMBOL_GPL(bcom_gen_bd_tx_release);
[ ... ]
> -static struct bcom_psc_params {
> +struct bcom_psc_params {
> int rx_initiator;
> int rx_ipr;
> int tx_initiator;
> int tx_ipr;
> -} bcom_psc_params[] = {
> +};
> +
> +static const struct bcom_psc_params bcom_psc_params[] = {
[Severity: High]
This is a pre-existing issue, but does this fixed-size array expose an
out-of-bounds access?
The array strictly contains 6 elements (indices 0 through 5). However,
bcom_psc_gen_bd_rx_init() checks the psc_num index against
MPC52xx_PSC_MAXNUM:
drivers/dma/bestcomm/gen_bd.c:bcom_psc_gen_bd_rx_init() {
if (psc_num >= MPC52xx_PSC_MAXNUM)
return NULL;
...
bcom_psc_params[psc_num].rx_initiator,
...
}
If CONFIG_PPC_MPC512x is enabled, MPC52xx_PSC_MAXNUM can be 12, allowing an
index up to 11 to access the 6-element bcom_psc_params[].
Additionally, bcom_psc_gen_bd_tx_init() appears to perform no bounds checking
on psc_num at all before indexing this array. Callers like
mpc5200_audio_dma_create() can pass an unvalidated cell-index from the
device tree directly into these functions.
Can a malformed device tree trigger out-of-bounds memory reads here, leading
to out-of-bounds MMIO writes when using the read garbage as the initiator
and ipr?
> [0] = {
> .rx_initiator = BCOM_INITIATOR_PSC1_RX,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260530012554.68605-1-rosenp@gmail.com?part=1
next prev parent reply other threads:[~2026-05-30 2:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 1:25 [PATCHv2] dma: bestcomm: gen_bd: split struct bcom_psc_params from array definition Rosen Penev
2026-05-30 2:19 ` sashiko-bot [this message]
2026-05-30 3:00 ` Rosen Penev
-- strict thread matches above, loose matches on Subject: below --
2026-05-30 2:54 Rosen Penev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260530021906.99C2B1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=rosenp@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox