Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move inject_entropy_with_timestamp() inside mutex protected sections #594

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 15 additions & 3 deletions core/arch/arm/kernel/tee_ta_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,14 @@ static TEE_Result check_client(struct tee_ta_session *s, const TEE_Identity *id)
return TEE_SUCCESS;
}

static void inject_entropy_with_timestamp(void)
{
TEE_Time current;

if (tee_time_get_sys_time(&current) == TEE_SUCCESS)
tee_prng_add_entropy((uint8_t *)&current, sizeof(current));
}

/*-----------------------------------------------------------------------------
* Close a Trusted Application and free available resources
*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -1354,6 +1362,13 @@ static TEE_Result tee_ta_init_session(TEE_ErrorOrigin *err,
*/
tee_ta_rpc_free(handle);

/*
* The occurrence of open/close session command is usually
* un-predictable, using this property to increase randomness
* of prng
*/
inject_entropy_with_timestamp();

out:
if (res == TEE_SUCCESS) {
*sess = s;
Expand All @@ -1365,9 +1380,6 @@ static TEE_Result tee_ta_init_session(TEE_ErrorOrigin *err,
return res;
}




TEE_Result tee_ta_open_session(TEE_ErrorOrigin *err,
struct tee_ta_session **sess,
struct tee_ta_session_head *open_sessions,
Expand Down
20 changes: 0 additions & 20 deletions core/kernel/tee_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

#include <kernel/tee_dispatch.h>

#include <kernel/tee_ta_manager.h>
#include <mm/core_memprot.h>
#include <mm/core_mmu.h>
#include <kernel/tee_compat.h>
#include <kernel/tee_time.h>
#include <tee/tee_cryp_utl.h>

/* Sessions opened from normal world */
Expand Down Expand Up @@ -81,14 +78,6 @@ static TEE_Result update_clnt_id(const TEE_Identity *in, TEE_Identity *out)
return TEE_SUCCESS;
}

static void inject_entropy_with_timestamp(void)
{
TEE_Time current;

if (tee_time_get_sys_time(&current) == TEE_SUCCESS)
tee_prng_add_entropy((uint8_t *)&current, sizeof(current));
}

TEE_Result tee_dispatch_open_session(struct tee_dispatch_open_session_in *in,
struct tee_dispatch_open_session_out *out)
{
Expand Down Expand Up @@ -116,13 +105,6 @@ TEE_Result tee_dispatch_open_session(struct tee_dispatch_open_session_in *in,
memcpy(out->params, in->params, sizeof(in->params));
update_out_param(&param, out->params);

/*
* The occurrence of open/close session command is usually
* un-predictable, using this property to increase randomness
* of prng
*/
inject_entropy_with_timestamp();

cleanup_return:
if (res != TEE_SUCCESS)
DMSG(" => Error: %x of %d", (unsigned int)res, (int)res_orig);
Expand All @@ -134,8 +116,6 @@ TEE_Result tee_dispatch_open_session(struct tee_dispatch_open_session_in *in,

TEE_Result tee_dispatch_close_session(struct tee_close_session_in *in)
{
inject_entropy_with_timestamp();

return tee_ta_close_session((struct tee_ta_session *)in->sess,
&tee_open_sessions, NSAPP_IDENTITY);
}
Expand Down