From: sashiko-bot@kernel.org
To: "Vincent Donnefort" <vdonnefort@google.com>,
catalin.marinas@arm.com, will@kernel.org, rppt@kernel.org,
akpm@linux-foundation.org, m.szyprowski@samsung.com,
jenswi@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org
Cc: mark.rutland@arm.com, robin.murphy@arm.com, hch@lst.de,
ryan.roberts@arm.com, sumit.garg@kernel.org,
sudeep.holla@kernel.org, ardb@kernel.org,
thierry.reding@kernel.org, david@kernel.org,
danielmentz@google.com, linux-mm@kvack.org,
op-tee@lists.trustedfirmware.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 8/8] optee: Add support for lendable-dma-pool
Date: Thu, 12 Nov 2026 11:08:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-210997@kernel.org> (raw)
In-Reply-To: <20261111110738.872947-9-vdonnefort@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] optee: restore_direct_map_dyn_protmem() called when
reclaim_protmem() fails
--
commit 1a801ca7487b0859c4bfdf62e4f1116b16a1b7fe
Author: Vincent Donnefort <vdonnefort@google.com>
optee: Add support for lendable-dma-pool
This commit uses dma_zap_direct_map() and dma_restore_direct_map() to
unmap dynamically allocated protected memory from the kernel linear map
before lending it to the secure world and restore it upon reclaim.
> diff --git a/drivers/tee/optee/protmem.c b/drivers/tee/optee/protmem.c
> index be3abf6e8aa6d..10e8f1540e5e8 100644
> --- a/drivers/tee/optee/protmem.c
> +++ b/drivers/tee/optee/protmem.c
[ ... ]
> @@ -76,6 +103,8 @@ static int init_dyn_protmem(struct optee_protmem_dyn_pool *rp)
> rp->gen_pool = NULL;
> err_reclaim:
> rp->optee->ops->reclaim_protmem(rp->optee, rp->protmem);
> +err_restore_direct_map:
> + restore_direct_map_dyn_protmem(rp);
> err_put_shm:
> tee_shm_put(rp->protmem);
> err_null_protmem:
> @@ -112,6 +141,7 @@ static void release_dyn_protmem(struct optee_protmem_dyn_pool *rp)
> rp->gen_pool = NULL;
>
> rp->optee->ops->reclaim_protmem(rp->optee, rp->protmem);
> + restore_direct_map_dyn_protmem(rp);
> rp->protmem->flags &= ~TEE_SHM_DYNAMIC;
>
> WARN(refcount_read(&rp->protmem->refcount) != 1, "Unexpected refcount");
[Severity: High]
Can restore_direct_map_dyn_protmem() run while rp->protmem is still lent
to the secure world if reclaim_protmem() fails?
reclaim_protmem() can fail, for example if optee_get_msg_arg() returns
-ENOMEM in optee_smc_reclaim_protmem() or if the secure world has not
relinquished the memory handle in optee_ffa_reclaim_protmem(). Both
init_dyn_protmem() and release_dyn_protmem() ignore that return value and
unconditionally call restore_direct_map_dyn_protmem(rp).
On arm64, arch_dma_restore_direct_map() remaps the pages as cacheable in
the linear map and runs dcache_inval_poc() across the range, which
re-exposes the still-lent pages to CPU speculative reads and triggers a
synchronous external abort or SError on the cache maintenance before
tee_shm_put() returns the pages to the allocator.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261111110738.872947-1-vdonnefort@google.com?part=8
prev parent reply other threads:[~2026-11-12 11:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 11:07 [PATCH v3 0/8] arm64: Unmap FF-A lent memory from direct map Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 1/8] memblock: Introduce MEMBLOCK_PTEMAP Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 2/8] arm64: Add support for MEMBLOCK_PTEMAP Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 3/8] dma-contiguous: Expose rmem_cma_ops Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 4/8] dt-bindings: reserved-memory: Add lendable-dma-pool Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 5/8] dma-mapping: Introduce lendable-dma-pool Vincent Donnefort
2026-11-12 11:08 ` sashiko-bot
2026-11-11 11:07 ` [PATCH v3 6/8] arm64: Introduce direct_map_is_ptemap() Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 7/8] arm64: Add support for lendable-dma-pool Vincent Donnefort
2026-11-11 11:07 ` [PATCH v3 8/8] optee: " Vincent Donnefort
2026-11-12 11:08 ` 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-210997@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=danielmentz@google.com \
--cc=david@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=hch@lst.de \
--cc=jenswi@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-mm@kvack.org \
--cc=m.szyprowski@samsung.com \
--cc=mark.rutland@arm.com \
--cc=op-tee@lists.trustedfirmware.org \
--cc=robh@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rppt@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sudeep.holla@kernel.org \
--cc=sumit.garg@kernel.org \
--cc=thierry.reding@kernel.org \
--cc=vdonnefort@google.com \
--cc=will@kernel.org \
/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