summaryrefslogtreecommitdiff
path: root/drivers/tee/optee/supp.c
diff options
context:
space:
mode:
authorJens Wiklander <jens.wiklander@linaro.org>2016-12-23 13:13:34 +0100
committerVictor Chong <victor.chong@linaro.org>2018-02-21 15:40:47 +0000
commit4883df6ebbcd0537d8052f76f8803bf86468e48c (patch)
tree34cc62e22056c196479772aea13828ac9c408964 /drivers/tee/optee/supp.c
parentfb96bdaa3aa30c7aa605b7ecf42df459b2b386e7 (diff)
BACKPORT: tee: add TEE_IOCTL_PARAM_ATTR_META
Adds TEE_IOCTL_PARAM_ATTR_META which can be used to indicate meta parameters when communicating with user space. These meta parameters can be used by supplicant support multiple parallel requests at a time. Change-Id: Id119468872ef96c941da0dfbbabed59e55366f12 Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> (cherry picked from commit f2aa97240c84b8f258710e297ba60048bd9c153e) Signed-off-by: Victor Chong <victor.chong@linaro.org>
Diffstat (limited to 'drivers/tee/optee/supp.c')
-rw-r--r--drivers/tee/optee/supp.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c
index b4ea0678a436..56aa8b929b8c 100644
--- a/drivers/tee/optee/supp.c
+++ b/drivers/tee/optee/supp.c
@@ -119,6 +119,27 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
return ret;
}
+static int supp_check_recv_params(size_t num_params, struct tee_param *params)
+{
+ size_t n;
+
+ /*
+ * If there's memrefs we need to decrease those as they where
+ * increased earlier and we'll even refuse to accept any below.
+ */
+ for (n = 0; n < num_params; n++)
+ if (tee_param_is_memref(params + n) && params[n].u.memref.shm)
+ tee_shm_put(params[n].u.memref.shm);
+
+ /*
+ * We only expect parameters as TEE_IOCTL_PARAM_ATTR_TYPE_NONE (0).
+ */
+ for (n = 0; n < num_params; n++)
+ if (params[n].attr)
+ return -EINVAL;
+ return 0;
+}
+
/**
* optee_supp_recv() - receive request for supplicant
* @ctx: context receiving the request
@@ -137,6 +158,10 @@ int optee_supp_recv(struct tee_context *ctx, u32 *func, u32 *num_params,
struct optee_supp *supp = &optee->supp;
int rc;
+ rc = supp_check_recv_params(*num_params, param);
+ if (rc)
+ return rc;
+
/*
* In case two threads in one supplicant is calling this function
* simultaneously we need to protect the data with a mutex which