Commit a41e95a7 authored by Arnd Bergmann's avatar Arnd Bergmann

Merge tag 'amdtee-fix-for-v6.6' of...

Merge tag 'amdtee-fix-for-v6.6' of https://git.linaro.org/people/jens.wiklander/linux-tee into arm/fixes

AMDTEE fix possible use-after-free

* tag 'amdtee-fix-for-v6.6' of https://git.linaro.org/people/jens.wiklander/linux-tee:
  tee: amdtee: fix use-after-free vulnerability in amdtee_close_session

Link: https://lore.kernel.org/r/20231003171835.GA669924@raydenSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 6465e260 f4384b3e
......@@ -217,12 +217,12 @@ static int copy_ta_binary(struct tee_context *ctx, void *ptr, void **ta,
return rc;
}
/* mutex must be held by caller */
static void destroy_session(struct kref *ref)
{
struct amdtee_session *sess = container_of(ref, struct amdtee_session,
refcount);
mutex_lock(&session_list_mutex);
list_del(&sess->list_node);
mutex_unlock(&session_list_mutex);
kfree(sess);
......@@ -272,7 +272,8 @@ int amdtee_open_session(struct tee_context *ctx,
if (arg->ret != TEEC_SUCCESS) {
pr_err("open_session failed %d\n", arg->ret);
handle_unload_ta(ta_handle);
kref_put(&sess->refcount, destroy_session);
kref_put_mutex(&sess->refcount, destroy_session,
&session_list_mutex);
goto out;
}
......@@ -290,7 +291,8 @@ int amdtee_open_session(struct tee_context *ctx,
pr_err("reached maximum session count %d\n", TEE_NUM_SESSIONS);
handle_close_session(ta_handle, session_info);
handle_unload_ta(ta_handle);
kref_put(&sess->refcount, destroy_session);
kref_put_mutex(&sess->refcount, destroy_session,
&session_list_mutex);
rc = -ENOMEM;
goto out;
}
......@@ -331,7 +333,7 @@ int amdtee_close_session(struct tee_context *ctx, u32 session)
handle_close_session(ta_handle, session_info);
handle_unload_ta(ta_handle);
kref_put(&sess->refcount, destroy_session);
kref_put_mutex(&sess->refcount, destroy_session, &session_list_mutex);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment