Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tee/kernel/entry_std.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,19 @@ TEEC_Result tee_ioctl_invoke(/*ctx,*/ struct tee_ioctl_buf_data *buf_data)
if (res != TEE_SUCCESS)
goto out;

if (!sess) {
/*
* A Non-Secure caller can supply an invalid/zero/stale session id.
* find_session() then returns NULL and, since the guards in
* tee_ta_invoke_command() are disabled, the secure world would
* dereference NULL (sess->ctx->...) -> secure-world crash/DoS.
* Reject before invoking. Placed after copy_in_params so a malformed
* request still gets the more specific error from parameter validation.
*/
res = TEEC_ERROR_BAD_PARAMETERS;
goto out;
}

res = tee_ta_invoke_command(&err, sess, arg->func, &param);

copy_out_param(&param, arg->num_params, arg->params, saved_attr);
Expand Down
9 changes: 9 additions & 0 deletions tee/kernel/tee_ta_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,15 @@ TEE_Result tee_ta_invoke_command(TEE_ErrorOrigin *err,
{
TEE_Result res;

/*
* Defense in depth: never dereference a NULL session. Callers (e.g. the
* Non-Secure ioctl veneer) obtain sess from tee_ta_get_session(), which
* returns NULL for an unknown session id; without this guard the line
* below would fault in the secure world.
*/
if (!sess)
return TEE_ERROR_BAD_PARAMETERS;

// if (check_client(sess, clnt_id) != TEE_SUCCESS)
// return TEE_ERROR_BAD_PARAMETERS; /* intentional generic error */
//
Expand Down
Loading