Skip to content

Commit

Permalink
core: tee_svc.c: allow to pass non-NULL memref of size 0
Browse files Browse the repository at this point in the history
Allow TAs to pass non-NULL memref of size zero to other TAs by
changing the non-NULL pointer into a NULL one in such a case. GP TEE
Internal Core API does not forbid such memref parameter [1] whereas
the previous implementation generated a TEE_ERROR_BAD_PARAMETERS error
code when converting such memref buffer pointer into a physical memory
address.

This change is specifically needed to allow a TA to forward a REE
client memref for which GP TEE Client API explicitly allows such
non-NULL address zero sized memref [2]. It also makes the TA
implementation more flexible when dealing with its own memref.

[1] TEE Internal Core API Specification – Public Release v1.3.1,
    §4.9.4 "Operation Parameters in the Internal Client API"
    Table 4-15: "Interpretation of params[i] on Entry to Internal Client
    API"

[2] TEE Client API Specification v1.0, §4.5.4 TEEC_RegisterSharedMemory,
    paragraph "Implementers' Notes"

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
  • Loading branch information
vincent-mailhol authored and jforissier committed Nov 20, 2023
1 parent ab3536f commit 4527964
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/tee/tee_svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,11 +700,13 @@ static TEE_Result tee_svc_copy_param(struct ts_session *sess,
case TEE_PARAM_TYPE_MEMREF_INOUT:
va = (void *)param->u[n].mem.offs;
s = param->u[n].mem.size;
if (!va) {
if (s)
return TEE_ERROR_BAD_PARAMETERS;
if (!s) {
param->u[n].mem.mobj = NULL;
break;
}
if (!va)
return TEE_ERROR_BAD_PARAMETERS;

/* uTA cannot expose its private memory */
if (vm_buf_is_inside_um_private(&utc->uctx, va, s))
return TEE_ERROR_BAD_PARAMETERS;
Expand Down

0 comments on commit 4527964

Please sign in to comment.