From: sashiko-bot@kernel.org
To: "Vincent Donnefort" <vdonnefort@google.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 6/8] optee: Add support for arm,ffa-lend-pool
Date: Mon, 21 Sep 2026 12:04:54 +0000 [thread overview]
Message-ID: <20260921120454.7E2FA1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921110050.3977591-7-vdonnefort@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] tee: optee: premature lend pool detachment prevents direct map restore
--
commit 4b4b22cda5d128d440dc2543a21dd2f20cdf757f
Author: Vincent Donnefort <vdonnefort@google.com>
optee: Add support for arm,ffa-lend-pool
Hook OP-TEE dynamically allocated protected memory pools to the
"arm,ffa-lend-pool" driver. While the SMC transport platform device
resolves the pool through its DT "memory-region" property, the FF-A
transport lacks a device tree node and binds via ffa_lend_pool_attach().
> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
> index a52c1f498b996..39f315cea830d 100644
> --- a/drivers/tee/optee/core.c
> +++ b/drivers/tee/optee/core.c
> @@ -201,6 +201,12 @@ void optee_remove_common(struct optee *optee)
> /* Unregister OP-TEE specific client devices on TEE bus */
> optee_unregister_devices();
>
> + /*
> + * Must follow optee_unregister_devices(). Clients require the lend pool
> + * linkage to successfully free their memory.
> + */
> + optee_lend_pool_unregister(optee);
> +
> optee_notif_uninit(optee);
> optee_shm_arg_cache_uninit(optee);
> teedev_close_context(optee->ctx);
[Severity: High]
Does detaching the lend pool here before tee_device_unregister() risk
leaving CMA pages unmapped?
If a user-space process holds a DMA buffer open during driver unbind,
tee_device_unregister() (called shortly after this) will block waiting for
the teedev refcount to drop to zero.
When the user-space process finally closes the buffer, release_dyn_protmem()
will invoke optee_lend_pool_reclaimed() to restore the direct map.
If optee_lend_pool_unregister() has already detached the pool, will the
direct map restore fail? This could cause the CMA pages to be returned to
the allocator unmapped, leading to a fatal synchronous data abort when the
kernel later accesses them.
[ ... ]
> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 633715b98625c..e979dbc9a5475 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -1172,6 +1180,7 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev)
>
> err_unregister_devices:
> optee_unregister_devices();
> + optee_lend_pool_unregister(optee);
> if (optee->ffa.bottom_half_value != U32_MAX)
> notif_ops->notify_relinquish(ffa_dev,
[Severity: High]
Does this error path in optee_ffa_probe() have the same issue with premature
detachment?
It seems optee_lend_pool_unregister() runs before err_unreg_teedev calls
tee_device_unregister(). If a DMA allocation was active during a probe
failure, the delayed cleanup might fail to restore the direct map.
[ ... ]
> diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
> index b8a2bdac3208f..e46eb881cf903 100644
> --- a/drivers/tee/optee/smc_abi.c
> +++ b/drivers/tee/optee/smc_abi.c
> @@ -1932,6 +1942,7 @@ static int optee_probe(struct platform_device *pdev)
> optee_disable_shm_cache(optee);
> optee_smc_notif_uninit_irq(optee);
> optee_unregister_devices();
> + optee_lend_pool_unregister(optee);
> err_notif_uninit:
> optee_notif_uninit(optee);
> err_close_ctx:
[Severity: High]
Does this error path in optee_probe() also detach the pool before
tee_device_unregister() ensures DMA buffers are closed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921110050.3977591-1-vdonnefort@google.com?part=6
next prev parent reply other threads:[~2026-09-21 12:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 11:00 [PATCH v2 0/8] arm64: Unmap FF-A lent memory from direct map Vincent Donnefort
2026-09-21 11:00 ` [PATCH v2 1/8] memblock: Introduce MEMBLOCK_PTEMAP Vincent Donnefort
2026-09-21 11:00 ` [PATCH v2 2/8] arm64: Introduce can_set_direct_map_range() Vincent Donnefort
2026-09-21 11:00 ` [PATCH v2 3/8] arm64: Introduce __set_direct_map*() Vincent Donnefort
2026-09-21 11:00 ` [PATCH v2 4/8] arm64: Add support for MEMBLOCK_PTEMAP Vincent Donnefort
2026-09-21 11:00 ` [PATCH v2 5/8] firmware: arm_ffa: Introduce ffa-lend-pool Vincent Donnefort
2026-09-21 11:48 ` sashiko-bot
2026-09-21 11:00 ` [PATCH v2 6/8] optee: Add support for arm,ffa-lend-pool Vincent Donnefort
2026-09-21 12:04 ` sashiko-bot [this message]
2026-09-21 11:00 ` [PATCH v2 7/8] dt-bindings: reserved-memory: Add Arm FF-A lend pool Vincent Donnefort
2026-09-21 15:20 ` Rob Herring (Arm)
2026-09-21 11:00 ` [PATCH v2 8/8] dt-bindings: firmware: optee: Add memory-region property Vincent Donnefort
2026-09-22 5:57 ` [PATCH v2 0/8] arm64: Unmap FF-A lent memory from direct map Sumit Garg
2026-09-22 10:57 ` Thierry Reding
2026-09-22 14:55 ` Will Deacon
2026-09-26 12:13 ` Sumit Garg
2026-09-29 11:33 ` Will Deacon
2026-10-01 12:34 ` Sumit Garg
2026-10-05 10:48 ` Vincent Donnefort
2026-10-05 11:02 ` Vincent Donnefort
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=20260921120454.7E2FA1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vdonnefort@google.com \
/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