From: Arun Iyengar via B4 Relay <devnull+aiyengar1990.gmail.com@kernel.org>
To: Jens Wiklander <jenswi@kernel.org>,
Sumit Garg <sumit.garg@kernel.org>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Cc: op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org,
Arun Iyengar <aiyengar1990@gmail.com>
Subject: [PATCH] tee: optee: release the supplicant when its device file is closed
Date: Sun, 15 Nov 2026 09:03:21 +0000 [thread overview]
Message-ID: <20261115-optee-supp-close-v1-1-4e0b14f3a97c@gmail.com> (raw)
From: Arun Iyengar <aiyengar1990@gmail.com>
optee_supp_release() runs only on the context's last reference, which
RPC shared memory can hold. If tee-supplicant exits during an RPC, the
next request waits forever and a new tee-supplicant gets -EBUSY.
Detach the supplicant in .close_context instead.
Fixes: 217e0250cccb ("tee: use reference counting for tee_context")
Signed-off-by: Arun Iyengar <aiyengar1990@gmail.com>
---
Tested on an Orange Pi 5 (RK3588S, SMC ABI), 7.3-based KASAN + lockdep
kernel: tee-supplicant stopped and restarted during fTPM NV writes, no
hung task; the fTPM TA then stays dead until a reboot. FF-A is
build-tested only.
Developed with Claude (Anthropic), which wrote the code and the commit
message. I reviewed it.
---
drivers/tee/optee/core.c | 4 +---
drivers/tee/optee/ffa_abi.c | 3 ++-
drivers/tee/optee/optee_private.h | 2 +-
drivers/tee/optee/smc_abi.c | 3 ++-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c
index a52c1f498b99..f446b40d7827 100644
--- a/drivers/tee/optee/core.c
+++ b/drivers/tee/optee/core.c
@@ -184,12 +184,10 @@ void optee_release(struct tee_context *ctx)
optee_release_helper(ctx, optee_close_session_helper);
}
-void optee_release_supp(struct tee_context *ctx)
+void optee_close_context_supp(struct tee_context *ctx)
{
struct optee *optee = tee_get_drvdata(ctx->teedev);
- optee_release_helper(ctx, optee_close_session_helper);
-
optee_supp_release(&optee->supp);
}
diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 702da7d98fbc..155ce9856de9 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -957,7 +957,8 @@ static const struct tee_driver_ops optee_ffa_supp_ops = {
.get_version = optee_ffa_get_version,
.get_tee_revision = optee_get_revision,
.open = optee_ffa_open,
- .release = optee_release_supp,
+ .close_context = optee_close_context_supp,
+ .release = optee_release,
.supp_recv = optee_supp_recv,
.supp_send = optee_supp_send,
.shm_register = optee_ffa_shm_register, /* same as for clnt ops */
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index 94a4f251f5cf..6495e0f07deb 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -370,7 +370,7 @@ void optee_set_dev_group(struct optee *optee);
void optee_remove_common(struct optee *optee);
int optee_open(struct tee_context *ctx, bool cap_memref_null);
void optee_release(struct tee_context *ctx);
-void optee_release_supp(struct tee_context *ctx);
+void optee_close_context_supp(struct tee_context *ctx);
static inline void optee_from_msg_param_value(struct tee_param *p, u32 attr,
const struct optee_msg_param *mp)
diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c
index 51624443359b..0278dc6b0119 100644
--- a/drivers/tee/optee/smc_abi.c
+++ b/drivers/tee/optee/smc_abi.c
@@ -1264,7 +1264,8 @@ static const struct tee_driver_ops optee_supp_ops = {
.get_version = optee_get_version,
.get_tee_revision = optee_get_revision,
.open = optee_smc_open,
- .release = optee_release_supp,
+ .close_context = optee_close_context_supp,
+ .release = optee_release,
.supp_recv = optee_supp_recv,
.supp_send = optee_supp_send,
.shm_register = optee_shm_register_supp,
---
base-commit: e21989d08e0d6abacfff71387d0cb36dd96a4079
change-id: 20261115-optee-supp-close-45df0ffe66b3
Best regards,
--
Arun Iyengar <aiyengar1990@gmail.com>
reply other threads:[~2026-11-15 9:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261115-optee-supp-close-v1-1-4e0b14f3a97c@gmail.com \
--to=devnull+aiyengar1990.gmail.com@kernel.org \
--cc=Volodymyr_Babchuk@epam.com \
--cc=aiyengar1990@gmail.com \
--cc=jenswi@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=op-tee@lists.trustedfirmware.org \
--cc=sumit.garg@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
all inboxes | Powered by JetHome®