From: sashiko-bot@kernel.org
To: "Amirreza Zarrabi" <amirreza.zarrabi@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH RFC v3 9/9] tee: optee: support RPMI asynchronous notification doorbells
Date: Tue, 13 Oct 2026 05:48:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-169011@kernel.org> (raw)
In-Reply-To: <20261012-rpmi-tee-service-grp-dev-v3-9-975b574667e2@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tee: optee: race between async notif callback and teardown causes UAF/NULL deref
--
commit fbdb2da759a2fc5e6692fd4d211f0b6f63644339
Author: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
tee: optee: support RPMI asynchronous notification doorbells
This commit introduces support for RPMI asynchronous notification doorbells
in OP-TEE. It allocates a TEE-to-REE RPMI signal, passes it to OP-TEE, and
queues bottom-half processing on a private workqueue. It also adds teardown
logic to stop asynchronous notifications and drain the workqueue upon
cleanup.
> diff --git a/drivers/tee/optee/rpmi_abi.c b/drivers/tee/optee/rpmi_abi.c
> index 0ed2de96758e2..6434767a22497 100644
> --- a/drivers/tee/optee/rpmi_abi.c
> +++ b/drivers/tee/optee/rpmi_abi.c
[ ... ]
> +static void optee_rpmi_notif_callback(struct rpmi_tee_device *rdev, u32 signal,
> + void *cb_data)
> +{
> + struct optee *optee = cb_data;
> +
> + queue_work(optee->rpmi.notif_wq, &optee->rpmi.notif_work);
> +}
> +
> +/* Relinquish is not a barrier for an already-selected transport callback. */
> +static void optee_rpmi_async_notif_uninit(struct optee *optee)
> +{
> + struct optee_rpmi *rpmi = &optee->rpmi;
> + struct rpmi_tee_device *rdev = rpmi->rdev;
> + int rc;
> +
> + if (!rpmi->notif_wq)
> + return;
> +
> + rc = optee_stop_async_notif(optee->ctx);
> + if (rc)
> + dev_warn(&rdev->dev, "stop notifications failed: %d\n", rc);
> +
> + rc = rdev->ops->notifier_ops->notify_relinquish(rdev, rpmi->signal);
> + if (rc && rc != -EOPNOTSUPP)
> + dev_warn(&rdev->dev,
> + "relinquish notification failed: %d\n", rc);
> +
> + destroy_workqueue(rpmi->notif_wq);
> +
> + rpmi->notif_wq = NULL;
> +}
[Severity: High]
Can an in-flight RPMI notification invoke optee_rpmi_notif_callback()
concurrently with or after this teardown process?
As the comment mentions, notify_relinquish() is not a barrier for an
already-selected transport callback. If the callback runs concurrently,
queue_work() accesses the workqueue without locking. This can cause a
use-after-free if destroy_workqueue() is executing, or a NULL pointer
dereference if rpmi->notif_wq has already been set to NULL.
Furthermore, if the callback execution is delayed until after
optee_rpmi_remove() completes, the optee structure itself is freed
via kfree(optee), which would lead to a use-after-free when the callback
dereferences optee->rpmi.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-rpmi-tee-service-grp-dev-v3-0-975b574667e2@oss.qualcomm.com?part=9
prev parent reply other threads:[~2026-10-13 5:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 5:41 [PATCH RFC v3 0/9] tee: optee: add RPMI backend support on RISC-V Amirreza Zarrabi
2026-10-13 5:41 ` [PATCH RFC v3 1/9] tee: optee: share the global shared-memory ID mapping Amirreza Zarrabi
2026-10-13 5:56 ` sashiko-bot
2026-10-13 5:41 ` [PATCH RFC v3 2/9] tee: optee: allow RPMI transport builds on RISC-V Amirreza Zarrabi
2026-10-13 5:55 ` sashiko-bot
2026-10-13 5:41 ` [PATCH RFC v3 3/9] tee: optee: define the RPMI control and parcel-reference ABI Amirreza Zarrabi
2026-10-13 5:41 ` [PATCH RFC v3 4/9] tee: optee: add RPMI shared-memory and parameter support Amirreza Zarrabi
2026-10-13 5:57 ` sashiko-bot
2026-10-13 5:41 ` [PATCH RFC v3 5/9] tee: optee: add RPMI dynamic shared-memory pool Amirreza Zarrabi
2026-10-13 5:41 ` [PATCH RFC v3 6/9] tee: optee: add RPMI RPC handling Amirreza Zarrabi
2026-10-13 5:59 ` sashiko-bot
2026-10-13 5:41 ` [PATCH RFC v3 7/9] tee: optee: execute yielding RPMI calls Amirreza Zarrabi
2026-10-13 5:56 ` sashiko-bot
2026-10-13 5:41 ` [PATCH RFC v3 8/9] tee: optee: bind RPMI services and negotiate backend capabilities Amirreza Zarrabi
2026-10-13 5:56 ` sashiko-bot
2026-10-13 5:41 ` [PATCH RFC v3 9/9] tee: optee: support RPMI asynchronous notification doorbells Amirreza Zarrabi
2026-10-13 5: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=sashiko-outbox-169011@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amirreza.zarrabi@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--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