From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>
Cc: Frank.Li@kernel.org, dmaengine@vger.kernel.org, vkoul@kernel.org
Subject: Re: [PATCHv3] dmaengine: bestcomm: gen_bd: fix out-of-bounds access in PSC parameter lookup
Date: Fri, 11 Sep 2026 21:48:26 +0000 [thread overview]
Message-ID: <20260911214827.367B61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911213747.132694-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch fails to completely resolve the vulnerability. The patch correctly addresses an out-of-bounds array access in `bcom_psc_gen_bd_rx_init()` by checking `psc_num >= ARRAY_SIZE(bcom_psc_params)`, but leaves the identical vulnerability unpatched in its sibling function `bcom_psc_gen_bd_tx_init()`. The author explicitly claims in the commit message that the TX bounds check was omitted because the function is 'not used anywhere anyway.' However, `bcom_psc_gen_bd_tx_init()` is exported and actively used in `sound/soc/fsl/mpc5200_dma.c`. In `mpc5200_audio_dma_create()`, `tx_init` is called unconditionally immediately after `rx_init`, reusing the exact same unvalidated device tree `cell-index`. If a malformed `cell-index` is provided, `rx_init` gracefully returns `NULL`, but execution continues to `tx_init`, where the unprotected out-of-bounds array read still occurs. These garbage values are then used as an index for an MMIO write in `bcom_gen_bd_tx_reset()`, resulting in a potentially severe out-of-bounds MMIO access.
--
commit fe70e15aeccf81a4b8cdfa4a3e93e93a4e989ae4
Author: Rosen Penev <rosenp@gmail.com>
dmaengine: bestcomm: gen_bd: fix out-of-bounds access in PSC parameter lookup
The bcom_psc_params[] array has 6 entries (indices 0-5), but
bcom_psc_gen_bd_rx_init() checked against MPC52xx_PSC_MAXNUM which can
be 12 when CONFIG_PPC_MPC512x is set, allowing indices 6-11 to pass
and read past the array.
A malformed device tree with a large cell-index could therefore trigger
an out-of-bounds read. The garbage initiator and ipr values would then
be used for MMIO writes via out_8(&bcom_eng->regs->ipr[...], ...),
potentially causing out-of-bounds MMIO accesses.
> diff --git a/drivers/dma/bestcomm/gen_bd.c b/drivers/dma/bestcomm/gen_bd.c
> index 8a24a5cbc2633..ce59a79325657 100644
> --- a/drivers/dma/bestcomm/gen_bd.c
> +++ b/drivers/dma/bestcomm/gen_bd.c
> @@ -315,7 +315,7 @@ static struct bcom_psc_params {
> struct bcom_task * bcom_psc_gen_bd_rx_init(unsigned psc_num, int queue_len,
> phys_addr_t fifo, int maxbufsize)
> {
> - if (psc_num >= MPC52xx_PSC_MAXNUM)
> + if (psc_num >= ARRAY_SIZE(bcom_psc_params))
> return NULL;
>
> return bcom_gen_bd_rx_init(queue_len, fifo,
[Severity: High]
This is a pre-existing issue, but does this patch fail to completely resolve
the vulnerability by leaving the identical out-of-bounds access unpatched in
the sibling function bcom_psc_gen_bd_tx_init()?
The bcom_psc_params array access in bcom_psc_gen_bd_tx_init() remains
completely unprotected by bounds checks:
drivers/dma/bestcomm/gen_bd.c:bcom_psc_gen_bd_tx_init() {
...
return bcom_gen_bd_tx_init(queue_len, fifo,
bcom_psc_params[psc_num].tx_initiator,
bcom_psc_params[psc_num].tx_ipr);
}
The patch omits the bounds check in the TX path on the assumption that the
function is unused, but the function is exported and actively used here:
sound/soc/fsl/mpc5200_dma.c:mpc5200_audio_dma_create() {
...
psc_dma->playback.bcom_task =
bcom_psc_gen_bd_tx_init(psc_dma->id, 10, fifo);
...
}
In mpc5200_audio_dma_create(), tx_init is called unconditionally immediately
after rx_init, reusing the exact same unvalidated device tree cell-index. If a
malformed cell-index is provided, rx_init gracefully returns NULL, but
execution continues to tx_init, where the unprotected out-of-bounds array read
still occurs.
These garbage values are then used as an index for an MMIO write in
bcom_gen_bd_tx_reset(), resulting in a potentially severe out-of-bounds MMIO
access:
drivers/dma/bestcomm/gen_bd.c:bcom_gen_bd_tx_reset() {
...
out_8(&bcom_eng->regs->ipr[priv->initiator], priv->ipr);
...
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911213747.132694-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-09-11 21:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 21:37 [PATCHv3] dmaengine: bestcomm: gen_bd: fix out-of-bounds access in PSC parameter lookup Rosen Penev
2026-09-11 21:48 ` sashiko-bot [this message]
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=20260911214827.367B61F000FF@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.