aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Carriere <etienne.carriere@linaro.org>2019-05-07 11:29:11 +0200
committerJérôme Forissier <jerome.forissier@linaro.org>2019-05-07 16:16:24 +0200
commit6e59bb1e95f0b3334d2f06a1312e9e395bb1232c (patch)
tree37fd628e6c7de53801a5dd0dca94412432d34f11
parentd62792a008c4cba8ab7f63c4abc733dcb5d7c17c (diff)
core: handle user TA context released from session
Change is_user_ta_ctx() to support NULL context reference. For such references the function now returns boolean value false. This allows caller to nicely abort their sequence when the context reference is already released from the session instance. Note that caller shall not assume a context refer to a PTA when is_user_ta_ctx() return false, it shall call is_pseudo_ta_ctx(). A side effect is that few test on reference and function return value can be simplified. This change also ensures TA dump_state() function does not crash when called provides a null context reference. Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
-rw-r--r--core/arch/arm/kernel/user_ta.c2
-rw-r--r--core/arch/arm/mm/tee_mmu.c4
-rw-r--r--core/arch/arm/mm/tee_pager.c2
-rw-r--r--core/kernel/tee_ta_manager.c9
4 files changed, 11 insertions, 6 deletions
diff --git a/core/arch/arm/kernel/user_ta.c b/core/arch/arm/kernel/user_ta.c
index a9bdae07..db587d97 100644
--- a/core/arch/arm/kernel/user_ta.c
+++ b/core/arch/arm/kernel/user_ta.c
@@ -525,7 +525,7 @@ static void set_ta_ctx_ops(struct tee_ta_ctx *ctx)
bool is_user_ta_ctx(struct tee_ta_ctx *ctx)
{
- return ctx->ops == _user_ta_ops;
+ return ctx && ctx->ops == _user_ta_ops;
}
static TEE_Result check_ta_store(void)
diff --git a/core/arch/arm/mm/tee_mmu.c b/core/arch/arm/mm/tee_mmu.c
index 68f0f53d..bb4ad279 100644
--- a/core/arch/arm/mm/tee_mmu.c
+++ b/core/arch/arm/mm/tee_mmu.c
@@ -817,9 +817,9 @@ void tee_mmu_set_ctx(struct tee_ta_ctx *ctx)
*
* Save translation tables in a cache if it's a user TA.
*/
- pgt_free(&tsd->pgt_cache, tsd->ctx && is_user_ta_ctx(tsd->ctx));
+ pgt_free(&tsd->pgt_cache, is_user_ta_ctx(tsd->ctx));
- if (ctx && is_user_ta_ctx(ctx)) {
+ if (is_user_ta_ctx(ctx)) {
struct core_mmu_user_map map;
struct user_ta_ctx *utc = to_user_ta_ctx(ctx);
diff --git a/core/arch/arm/mm/tee_pager.c b/core/arch/arm/mm/tee_pager.c
index 4d171918..76a53067 100644
--- a/core/arch/arm/mm/tee_pager.c
+++ b/core/arch/arm/mm/tee_pager.c
@@ -581,7 +581,7 @@ static struct tee_pager_area *find_uta_area(vaddr_t va)
{
struct tee_ta_ctx *ctx = thread_get_tsd()->ctx;
- if (!ctx || !is_user_ta_ctx(ctx))
+ if (!is_user_ta_ctx(ctx))
return NULL;
return find_area(to_user_ta_ctx(ctx)->areas, va);
}
diff --git a/core/kernel/tee_ta_manager.c b/core/kernel/tee_ta_manager.c
index 8b9ccf56..ce6a93de 100644
--- a/core/kernel/tee_ta_manager.c
+++ b/core/kernel/tee_ta_manager.c
@@ -330,7 +330,7 @@ static bool check_params(struct tee_ta_session *sess,
* When CFG_SECURE_DATA_PATH is enabled, OP-TEE entry allows SHM and
* SDP memory references. Only TAs flagged SDP can access SDP memory.
*/
- if (sess->ctx->flags & TA_FLAG_SECURE_DATA_PATH)
+ if (sess->ctx && sess->ctx->flags & TA_FLAG_SECURE_DATA_PATH)
return true;
for (n = 0; n < TEE_NUM_PARAMS; n++) {
@@ -734,7 +734,7 @@ static void update_current_ctx(struct thread_specific_data *tsd)
* If ctx->mmu == NULL we must not have user mapping active,
* if ctx->mmu != NULL we must have user mapping active.
*/
- if (((ctx && is_user_ta_ctx(ctx) ?
+ if (((is_user_ta_ctx(ctx) ?
to_user_ta_ctx(ctx)->vm_info : NULL) == NULL) ==
core_mmu_user_mapping_is_active())
panic("unexpected active mapping");
@@ -787,6 +787,11 @@ static void dump_state(struct tee_ta_ctx *ctx)
struct tee_ta_session *s = NULL;
bool active __maybe_unused;
+ if (!ctx) {
+ EMSG("No TA status: null context reference");
+ return;
+ }
+
active = ((tee_ta_get_current_session(&s) == TEE_SUCCESS) &&
s && s->ctx == ctx);