Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 5/5] remoteproc: imx_rproc: Invoke the callback directly
Date: Fri, 29 May 2026 19:08:53 +0000	[thread overview]
Message-ID: <20260529190854.1680E1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260529-imx_mbox_rproc-v1-5-b8ffc36e11e5@linutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unprotected access to `rproc->notifyids` in `imx_rproc_rx_callback` via `idr_for_each` without `rcu_read_lock()` can race with `idr_remove` during `rproc-virtio` unbind, leading to Use-After-Free.
--

commit 54541ad2eee46e430bd395ed2d5711955d46ef22
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

remoteproc: imx_rproc: Invoke the callback directly

The imx-mailbox driver moved callback invocation into the threaded IRQ
handler, making it run in a preemptible context. This patch removes the
workqueue and invokes the imx_rproc_notified_idr_cb() callback directly
from the RX callback.

> diff --git a/drivers/remoteproc/imx_rproc.c b/drivers/remoteproc/imx_rproc.c
> index 0dd80e688b0ea..c97bc1c401655 100644
> --- a/drivers/remoteproc/imx_rproc.c
> +++ b/drivers/remoteproc/imx_rproc.c

[ ... ]

>  static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
>  {
>  	struct rproc *rproc = dev_get_drvdata(cl->dev);
> -	struct imx_rproc *priv = rproc->priv;
>  
> -	queue_work(priv->workqueue, &priv->rproc_work);
> +	idr_for_each(&rproc->notifyids, imx_rproc_notified_idr_cb, rproc);

[Severity: High]
This is a pre-existing issue, but does this idr_for_each() call require
rcu_read_lock() protection?

Looking at the call chain, it also performs an idr_find() in
rproc_vq_interrupt() without rcu_read_lock():

imx_rproc_rx_callback()
  -> idr_for_each()
     -> imx_rproc_notified_idr_cb()
        -> rproc_vq_interrupt()
           -> idr_find()

If a user unbinds the rproc-virtio driver via sysfs concurrently,
rproc_virtio_remove() calls rproc_free_vring() which executes idr_remove().

Since idr_for_each() and idr_find() rely on RCU internally to protect radix
tree nodes, could running this in a preemptible context without
rcu_read_lock() race with idr_remove() and lead to a use-after-free of the
IDR nodes or the rvring structure?

>  }
>  
>  static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260529-imx_mbox_rproc-v1-0-b8ffc36e11e5@linutronix.de?part=5

  reply	other threads:[~2026-05-29 19:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 16:01 [PATCH 0/5] mailbox: imx: Use threaded handler to avoid kworker in imx's remoteproc Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 1/5] mailbox: imx: Start splitting the IRQ handler in primary and threaded handler Sebastian Andrzej Siewior
2026-05-29 16:43   ` sashiko-bot
2026-06-01 15:28     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 2/5] mailbox: imx: Move the RX part of the mailbox into the " Sebastian Andrzej Siewior
2026-05-29 17:26   ` sashiko-bot
2026-06-01 16:07     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 3/5] mailbox: imx: Move the RXDB " Sebastian Andrzej Siewior
2026-05-29 17:34   ` sashiko-bot
2026-06-01 16:15     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 4/5] mailbox: imx: Don't force-thread the primary handler Sebastian Andrzej Siewior
2026-05-29 18:13   ` sashiko-bot
2026-06-02 10:03     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 5/5] remoteproc: imx_rproc: Invoke the callback directly Sebastian Andrzej Siewior
2026-05-29 19:08   ` sashiko-bot [this message]
2026-06-02 12:11     ` Sebastian Andrzej Siewior
2026-06-02 16:51 ` [PATCH 0/5] mailbox: imx: Use threaded handler to avoid kworker in imx's remoteproc Mathieu Poirier

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=20260529190854.1680E1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=imx@lists.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox