From: sashiko-bot@kernel.org
To: "Richard Leitner" <richard.leitner@linux.dev>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] remoteproc: imx_rproc: revert channel freeing order in imx_rproc_free_mbox
Date: Tue, 10 Nov 2026 12:46:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-207041@kernel.org> (raw)
In-Reply-To: <20261110-imx-rproc-free-mbox-v1-1-3e33ff98570d@linux.dev>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] remoteproc: imx_rproc: dangling pointers in
imx_rproc_xtr_mbox_init() [1]
--
commit 47b24cc41389cd2e5e7dc88e20cee4c1d32a5d30
Author: Richard Leitner <richard.leitner@linux.dev>
remoteproc: imx_rproc: revert channel freeing order in imx_rproc_free_mbox
This commit frees the rx mailbox channel before the tx channel in
imx_rproc_free_mbox() to prevent an rx callback from kicking virtqueues
through a freed tx channel during shutdown.
> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 581bb07f5893f..232da31a56ebe 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c
> @@ -920,15 +920,16 @@ static void imx_rproc_free_mbox(void *data)
> struct rproc *rproc = data;
> struct imx_rproc *priv = rproc->priv;
>
> - if (priv->tx_ch) {
> - mbox_free_channel(priv->tx_ch);
> - priv->tx_ch = NULL;
> - }
> -
> + /* First release rx channel as its callback may kick vqs via tx_ch. */
> if (priv->rx_ch) {
> mbox_free_channel(priv->rx_ch);
> priv->rx_ch = NULL;
> }
> +
> + if (priv->tx_ch) {
> + mbox_free_channel(priv->tx_ch);
> + priv->tx_ch = NULL;
> + }
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can imx_rproc_free_mbox()
pass an ERR_PTR and a dangling pointer to mbox_free_channel() [1] if
requesting the rx channel fails in imx_rproc_xtr_mbox_init()?
drivers/remoteproc/imx_rproc.c:imx_rproc_xtr_mbox_init() {
...
if (priv->tx_ch && priv->rx_ch)
return 0;
...
priv->rx_ch = mbox_request_channel_byname(cl, "rx");
if (IS_ERR(priv->rx_ch)) {
mbox_free_channel(priv->tx_ch);
return dev_err_probe(cl->dev, PTR_ERR(priv->rx_ch),
"failed to request rx mailbox channel\n");
}
}
When mbox_request_channel_byname(cl, "rx") fails during rproc start or
attach, priv->tx_ch is freed without being cleared and priv->rx_ch is left
holding an ERR_PTR. Because both fields remain non-NULL, a subsequent start
retry passes the (priv->tx_ch && priv->rx_ch) check without initializing the
channels and later causes a use-after-free on priv->tx_ch in
imx_rproc_kick(), while unbinding the device causes the devm action
imx_rproc_free_mbox() to call mbox_free_channel() on both invalid pointers.
[1] https://sashiko.dev/#/bug/linux-ac0f248a-bdfd-41da-95f8-44b8f1f7091d
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261110-imx-rproc-free-mbox-v1-1-3e33ff98570d@linux.dev?part=1
next prev parent reply other threads:[~2026-11-10 12:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 12:29 [PATCH] remoteproc: imx_rproc: revert channel freeing order in imx_rproc_free_mbox Richard Leitner
2026-11-10 12:46 ` sashiko-bot [this message]
2026-11-10 13:46 ` Peng Fan
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=sashiko-outbox-207041@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=richard.leitner@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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.