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 7/9] tee: optee: execute yielding RPMI calls
Date: Tue, 13 Oct 2026 05:56:59 +0000 [thread overview]
Message-ID: <sashiko-outbox-169022@kernel.org> (raw)
In-Reply-To: <20261012-rpmi-tee-service-grp-dev-v3-7-975b574667e2@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] optee: missing bounds check on rpc_arg->num_params allows OOB access
--
commit 5f5afbcfcd90452c0729b00f504945e1e4f52c26
Author: Amirreza Zarrabi <amirreza.zarrabi@oss.qualcomm.com>
tee: optee: execute yielding RPMI calls
This patch adds the RPMI yielding-call path used by the common OP-TEE
session operations. It submits the command and RPC argument buffers as
ranges within a shared memory parcel and handles RPC requests while the
call is suspended.
> diff --git a/drivers/tee/optee/rpmi_abi.c b/drivers/tee/optee/rpmi_abi.c
> index 8b90c3653e80d..9a6439e15a33f 100644
> --- a/drivers/tee/optee/rpmi_abi.c
> +++ b/drivers/tee/optee/rpmi_abi.c
[ ... ]
> +static int optee_rpmi_yielding_call(struct tee_context *ctx,
> + const struct optee_rpmi_call_req *req,
> + struct optee_msg_arg *rpc_arg,
> + bool system_thread)
> +{
[ ... ]
> + result = le32_to_cpu(resp.result);
> + if (result == OPTEE_RPMI_YIELDING_CALL_RETURN_DONE)
> + goto done;
> +
> + cond_resched();
> + optee_rpmi_handle_rpc(ctx, optee, result, rpc_arg);
[Severity: High]
Does this code allow an out-of-bounds access if the firmware returns a
maliciously large num_params?
In optee_rpmi_do_call_with_arg() below, the RPC buffer is bounded in shared
memory by optee->rpc_param_count.
However, when the firmware populates rpc_arg and optee_rpmi_handle_rpc()
is called here, the num_params field isn't validated. The call chain
optee_rpmi_handle_rpc()->optee_rpmi_handle_rpc_cmd()->optee_rpc_cmd() reaches
handle_rpc_supp_cmd() in drivers/tee/optee/rpc.c, which uses the unvalidated
num_params:
params = kmalloc_objs(struct tee_param, arg->num_params);
if (!params) {
arg->ret = TEEC_ERROR_OUT_OF_MEMORY;
return;
}
if (optee->ops->from_msg_param(optee, params, arg->num_params,
arg->params)) {
This processes the RPC arguments using the firmware-supplied arg->num_params,
which can lead to out-of-bounds reads and writes on the arg->params shared
memory array if arg->num_params > optee->rpc_param_count.
[ ... ]
> +static int optee_rpmi_do_call_with_arg(struct tee_context *ctx,
> + struct tee_shm *shm, u_int offs,
> + bool system_thread)
> +{
> + struct optee *optee = tee_get_drvdata(ctx->teedev);
> + struct optee_msg_arg *arg, *rpc_arg;
[ ... ]
> + arg_size = OPTEE_MSG_GET_ARG_SIZE(arg->num_params);
> + rpc_size = OPTEE_MSG_GET_ARG_SIZE(optee->rpc_param_count);
> + rpc_offset = offs + arg_size;
> + rpc_arg = tee_shm_get_va(shm, rpc_offset);
> + if (IS_ERR(rpc_arg))
> + return PTR_ERR(rpc_arg);
> +
> + req.arg_offset = cpu_to_le64((u64)shm->offset + offs);
> + req.rpc_offset = cpu_to_le64((u64)shm->offset + rpc_offset);
> + req.arg_size = cpu_to_le32(arg_size);
> + req.rpc_size = cpu_to_le32(rpc_size);
> +
> + return optee_rpmi_yielding_call(ctx, &req, rpc_arg, system_thread);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-rpmi-tee-service-grp-dev-v3-0-975b574667e2@oss.qualcomm.com?part=7
next prev parent reply other threads:[~2026-10-13 5:56 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 [this message]
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
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-169022@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