diff options
author | Arnd Bergmann <arnd@arndb.de> | 2023-10-06 22:45:02 +0200 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2023-10-06 22:45:03 +0200 |
commit | a41e95a7c19b02e8a180520ea21c742e52ea538a (patch) | |
tree | 9650e179cc88d7e77f0c9ee33b2feede73d1c1fd | |
parent | 6465e260f48790807eef06b583b38ca9789b6072 (diff) | |
parent | f4384b3e54ea813868bb81a861bf5b2406e15d8f (diff) | |
download | linux-a41e95a7c19b02e8a180520ea21c742e52ea538a.tar.gz |
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@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | drivers/tee/amdtee/core.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c index 372d64756ed64..3c15f6a9e91c0 100644 --- a/drivers/tee/amdtee/core.c +++ b/drivers/tee/amdtee/core.c @@ -217,12 +217,12 @@ unlock: 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; } |