From: Sumit Garg via OP-TEE <op-tee@lists.trustedfirmware.org>
To: Jens Wiklander <jens.wiklander@linaro.org>
Cc: "Shf Chen (陳少甫)" <Shf.Chen@mediatek.com>,
"op-tee@lists.trustedfirmware.org"
<op-tee@lists.trustedfirmware.org>
Subject: Re: Possible race during OP-TEE kernel module device probing
Date: Mon, 30 Mar 2026 15:21:12 +0530 [thread overview]
Message-ID: <acpHkOJhmCkMadHj@sumit-xelite> (raw)
In-Reply-To: <CAHUa44EcGEoBcx2J4dOJOSNjE7E9=qCivdfJtFzgrHmqKKB8Fg@mail.gmail.com>
On Mon, Mar 30, 2026 at 11:16:59AM +0200, Jens Wiklander wrote:
> Hi,
>
> On Mon, Mar 30, 2026 at 6:07 AM Shf Chen (陳少甫) via OP-TEE
> <op-tee@lists.trustedfirmware.org> wrote:
> >
> > On Fri, 2026-03-27 at 15:31 +0530, Sumit Garg wrote:
> > > On Fri, Mar 27, 2026 at 09:01:15AM +0000, Shf Chen (陳少甫) via OP-TEE wrote:
> > > > Hi,
> > > >
> > > > We found a possible race condition issue during OP-TEE kernel driver probing the device.
> > > > A NULL pointer dereference exception can happen when another kernel driver open OP-TEE context
> > > > with tee_client_open_context() then do a SMC call to OP-TEE.
> > > > Below is the exception:
> > >
> > > How is your kernel driver being probed? Have you registered it as a
> > > proper TEE bus driver? Any custom ways to invoke TEE kernel client APIs
> > > are surely susceptible to races like the one you mentioned below.
> > >
> > > -Sumit
> >
> > Hi,
> >
> > Our kernel driver does not registered as a TEE bus driver for some reasons,
> > and we need to use other API to ensure the OP-TEE driver is probed to
> > workaround this issue. But, we think this is error-prone for module developer
> > that need to call to OP-TEE.
The kernel modules API for OP-TEE is via TEE bus only.
> >
> > Although this is not the case, I think that after calling tee_device_register(),
> > the optee device is shown under `/dev/` filesystem. There is a very small chance
> > for userspace program to trigger this race condition, and they don't have clue on
> > whether the device is properly being probed yet.
>
> I think you're on to something. After calling tee_device_register(),
> the driver must be able to handle requests, at least without crashing.
> optee_enumerate_devices() requires the devices to be registered, so
> that must happen after those calls. But other than that, I think the
> calls to tee_device_register() should be the last thing in the probe
> function.
>
> Sumit, do you agree?
>
Sounds reasonable to me if it's something that can be reproduced via
the user-space client.
-Sumit
prev parent reply other threads:[~2026-03-30 9:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 9:01 Possible race during OP-TEE kernel module device probing Shf Chen (陳少甫) via OP-TEE
2026-03-27 10:01 ` Sumit Garg via OP-TEE
2026-03-30 4:06 ` Shf Chen (陳少甫) via OP-TEE
2026-03-30 9:16 ` Jens Wiklander
2026-03-30 9:51 ` Sumit Garg via OP-TEE [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=acpHkOJhmCkMadHj@sumit-xelite \
--to=op-tee@lists.trustedfirmware.org \
--cc=Shf.Chen@mediatek.com \
--cc=jens.wiklander@linaro.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