From: sashiko-bot@kernel.org
To: "Ekansh Gupta" <ekansh.gupta@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/2] misc: fastrpc: use fastrpc_cb_devices_destroy() in probe error path
Date: Thu, 03 Dec 2026 05:59:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-247218@kernel.org> (raw)
In-Reply-To: <20261203-fastrpc-probe-ordering-fix-v1-2-b5e56e5c895f@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] misc: fastrpc: UAF of CB devices freed by
fastrpc_cb_devices_destroy()
- [Low] misc: fastrpc: commit log misses that of_platform_depopulate()
was a no-op
- [Low] misc: fastrpc: inaccurate commit message and Fixes attribution
--
commit 64e6c11d9bcb9cc1584f86ad076bfec7bd18df7d
Author: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
> misc: fastrpc: use fastrpc_cb_devices_destroy() in probe error path
>
> Since commit 81b3908cf7b9 ("misc: fastrpc: iterate CB nodes manually
> instead of of_platform_populate"), the CB devices are created by
> fastrpc_cb_devices_create(), but the probe error path still tears them
> down with of_platform_depopulate().
>
> Use fastrpc_cb_devices_destroy(), as fastrpc_rpmsg_remove() already
> does, so that the sessions are invalidated under the channel lock
> before the CB devices are removed.
[Severity: Low]
Does the commit message understate what this change fixes?
fastrpc_cb_devices_create() creates child devices individually via
of_platform_device_create() and never sets OF_POPULATED_BUS on
rdev->of_node. Because of_platform_depopulate() returns immediately when
OF_POPULATED_BUS is unset, it was a complete no-op that leaked the CB
platform devices and left OF_POPULATED set on their DT nodes, causing
later re-probes to fail with -ENODEV.
In addition, cctx->session[i].valid is only checked in
fastrpc_session_alloc() during fastrpc_device_open(), which
misc_deregister() has already prevented before err_depopulate runs.
> Fixes: 81b3908cf7b9 ("misc: fastrpc: iterate CB nodes manually instead of of_platform_populate")
> Co-developed-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
> Signed-off-by: Vinayak Katoch <vinayak.katoch@oss.qualcomm.com>
> Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
[Severity: Low]
Is this Fixes: tag pointing to the right commit?
Commit 81b3908cf7b9 ("misc: fastrpc: iterate CB nodes manually instead of
of_platform_populate") had no err_depopulate label or
of_platform_depopulate() call. Commit 367972113065 ("misc: fastrpc: fix
init ordering race in rpmsg probe") added err_depopulate on a branch that
still used of_platform_populate(), and the mismatch was introduced by the
merge commit 3680d0d62e9c ("Merge branch 'fastrpc-for-v7.5' into
fastrpc-for-next"). If that merge commit is permanent in history, the
commit message and Fixes: tag should reference it instead.
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index cb0972722e083..ff8a94cc522d2 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -2854,7 +2854,7 @@ static int fastrpc_rpmsg_probe(struct rpmsg_device *rpdev)
> fastrpc_notify_users(user);
> spin_unlock_irqrestore(&data->lock, flags);
>
> - of_platform_depopulate(rdev);
> + fastrpc_cb_devices_destroy(rpdev);
> fastrpc_channel_ctx_put(data);
> return err;
[Severity: High]
Can calling fastrpc_cb_devices_destroy() here trigger a use-after-free on
the freed CB struct device?
On CDSP and GDSP, fastrpc_rpmsg_probe() registers secure_fdevice before
fdevice, so userspace can open the first node before the second
fastrpc_device_register() fails and jumps to err_depopulate. Neither
fastrpc_cb_init() nor __fastrpc_buf_alloc() takes a get_device() reference
on the CB device, and clearing session[i].valid only blocks new opens.
CPU0 (probe error path) CPU1 / kworker
fastrpc_rpmsg_probe()
fastrpc_device_register(secure)
fastrpc_device_open()
fl->sctx = &cctx->session[i]
/* allocate buf / submit invoke */
fastrpc_device_register(non-sec) -> fails
misc_deregister(...)
fastrpc_notify_users()
fastrpc_context_schedule_put_work()
fastrpc_cb_devices_destroy()
of_platform_device_destroy()
platform_device_unregister() /* frees CB struct device */
fastrpc_context_put_wq()
fastrpc_buf_free(ctx->buf)
dma_free_coherent(buf->dev, ...)
<-- use-after-free
Because of_platform_depopulate() was previously a no-op, this change
newly exposes the probe error path to freeing the CB platform devices
while scheduled put_work, open fds (e.g. fastrpc_dmabuf_alloc()), and
exported dma-bufs still dereference fl->sctx->dev and buf->dev, causing
kernel memory corruption or a panic. (The same underlying
fastrpc_cb_devices_destroy() issue also affects fastrpc_rpmsg_remove().)
Should sessions and buffers hold a get_device() reference, or should CB
device teardown wait until the last channel context reference is dropped
in fastrpc_channel_ctx_free()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-fastrpc-probe-ordering-fix-v1-0-b5e56e5c895f@oss.qualcomm.com?part=2
prev parent reply other threads:[~2026-12-03 5:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 5:41 [PATCH 0/2] misc: fastrpc: fix session setup and teardown ordering in probe Ekansh Gupta
2026-12-03 5:41 ` [PATCH 1/2] misc: fastrpc: create ADSP duplicate sessions before registering devices Ekansh Gupta
2026-12-03 5:41 ` [PATCH 2/2] misc: fastrpc: use fastrpc_cb_devices_destroy() in probe error path Ekansh Gupta
2026-12-03 5:59 ` 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=sashiko-outbox-247218@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ekansh.gupta@oss.qualcomm.com \
--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