[Bugfix][T108][bug-view-1825]Fix the issue where multiple processes cannot be initialized simultaneously
Only Configure: No
Affected branch: GSW_V1453
Affected module: tee
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no
Change-Id: Iaeff61497771aa2e244bd27befc6d6d603c54aa7
diff --git a/mbtk/libgsw_lib/gsw_secrypt_ss_interface.c b/mbtk/libgsw_lib/gsw_secrypt_ss_interface.c
index d724b0b..6013227 100755
--- a/mbtk/libgsw_lib/gsw_secrypt_ss_interface.c
+++ b/mbtk/libgsw_lib/gsw_secrypt_ss_interface.c
@@ -161,7 +161,7 @@
int (*prepare_tee_session)(struct test_ctx *ctx);
void (*terminate_tee_session)(struct test_ctx *ctx);
-TEEC_Result (*read_secure_object)(struct test_ctx *ctx, const char *id,char *data, size_t data_len);
+TEEC_Result (*read_secure_object)(struct test_ctx *ctx, const char *id,char *data, size_t *data_len);
TEEC_Result (*write_secure_object)(struct test_ctx *ctx, const char *id,char *data, size_t data_len);
TEEC_Result (*delete_secure_object)(struct test_ctx *ctx, const char *id);
@@ -206,7 +206,7 @@
return GSW_HAL_NORMAL_FAIL;
}
- read_secure_object = (TEEC_Result (*)(struct test_ctx *ctx, const char *id,char *data, size_t data_len))dlsym(dlHandle_secure, "read_secure_object");
+ read_secure_object = (TEEC_Result (*)(struct test_ctx *ctx, const char *id,char *data, size_t *data_len))dlsym(dlHandle_secure, "read_secure_object");
if (read_secure_object == NULL)
{
LOGE("read_secure_object dlsym fail\n");
@@ -246,7 +246,7 @@
return ret;
}
ret = prepare_tee_session(&ctx);
-
+ LOGE("init end\n");
return ret;
}
@@ -261,12 +261,14 @@
#define basic_buf_len 7000
int32_t gsw_tee_read_secure_data(const char* in_obj_name, char* out_buf, unsigned int* p_out_buf_len)
{
+ LOGE("start read\n");
if (in_obj_name == NULL || out_buf == NULL)
{
return GSW_HAL_NORMAL_FAIL;
}
-
+
int32_t ret = 0;
+ size_t size = basic_buf_len;
char *tmp_buf = (char*)malloc(basic_buf_len);
if (NULL == tmp_buf)
{
@@ -274,14 +276,15 @@
return GSW_HAL_NO_MEMORY;
}
- TEEC_Result res = read_secure_object(&ctx, in_obj_name, tmp_buf, basic_buf_len);
+ TEEC_Result res = read_secure_object(&ctx, in_obj_name, tmp_buf, &size);
if (res != TEEC_SUCCESS)
{
LOGE("Failed to read an object from the secure storage");
ret = GSW_HAL_NORMAL_FAIL;
}
- memcpy(out_buf, tmp_buf, strlen(tmp_buf)+1);
- *p_out_buf_len = strlen(out_buf);
+ LOGE("really start end\n");
+ memcpy(out_buf, tmp_buf, size);
+ *p_out_buf_len = size;
free(tmp_buf);
return ret;
}
@@ -295,6 +298,7 @@
*/
int32_t gsw_tee_write_secure_data(const char* in_obj_name, char* in_buf, unsigned int in_buf_len)
{
+ LOGE("write start\n");
if (in_obj_name == NULL || in_buf == NULL)
return GSW_HAL_NORMAL_FAIL;
int32_t ret = 0;
@@ -305,7 +309,7 @@
LOGE("Failed to write an object from the secure storage");
ret = GSW_HAL_NORMAL_FAIL;
}
-
+ LOGE("write really end\n");
return ret;
}
@@ -317,6 +321,7 @@
*/
int32_t gsw_tee_delete_secure_data(const char* in_obj_name)
{
+ LOGE("delete start\n");
if (in_obj_name == NULL)
return GSW_HAL_NORMAL_FAIL;
int32_t ret = 0;
@@ -327,7 +332,7 @@
LOGE("Failed to delete the object: 0x%x", res);
ret = GSW_HAL_NORMAL_FAIL;
}
-
+ LOGE("delete really end\n");
return ret;
}
@@ -341,14 +346,14 @@
if (in_obj_name == NULL)
return GSW_HAL_NORMAL_FAIL;
int32_t ret = 1;
-
+ size_t size = basic_buf_len;
char *tmp_buf = (char*)malloc(basic_buf_len);
if (NULL == tmp_buf)
{
LOGE("Failed malloc fail");
return GSW_HAL_NO_MEMORY;
}
- TEEC_Result res = read_secure_object(&ctx, in_obj_name, tmp_buf, basic_buf_len);
+ TEEC_Result res = read_secure_object(&ctx, in_obj_name, tmp_buf, &size);
if (res == TEEC_ERROR_ITEM_NOT_FOUND)
{
LOGE("the obj no found\n");
@@ -376,6 +381,7 @@
*/
int32_t gsw_tee_sdk_deinit(void)
{
+ LOGE("deinit start\n");
if (terminate_tee_session) {
terminate_tee_session(&ctx); // 终止TEE会话
terminate_tee_session = NULL;
@@ -390,7 +396,7 @@
dlclose(dlHandle_mbtk); // 卸载日志库
dlHandle_mbtk = NULL;
}
-
+ LOGE("deinit end\n");
return GSW_HAL_SUCCESS;
}