Skip to content

issues for multiple operations on persistent objects  #798

@sidalit

Description

@sidalit

Hi,

I'm experiencing some problems when using multiple operations on persistent objects.

I'm using optee_os 2.0.0 and qemu.
I hadn't this problem on optee_os 1.0.0

I tried to write simple code to reproduce the issue on qemu because it happens randomly depending on the number of operation performed on one or multiple persistent objects and the platform used.

For example the code below panics at the 10h iteration
TEE_ObjectHandle object = TEE_HANDLE_NULL;

int object_id = 0;

uint32_t flags =  TEE_DATA_FLAG_OVERWRITE | TEE_DATA_FLAG_ACCESS_WRITE_META;

int i = 0;

while (i < 20) {

    IMSG("\n\nLOOP : %d", i+1);

    TEE_CreatePersistentObject(TEE_STORAGE_PRIVATE, &object_id, sizeof(int), flags, 
                               TEE_HANDLE_NULL, NULL, 0, &object);

    TEE_CloseAndDeletePersistentObject1(object);

    i++;
} 
Output :
LOOP : 10
ERROR:   TEE-CORE: ERROR:   USER-TA: Panic 0x0
ERROR:   TEE-CORE: TA panicked with code 0x0 usr_sp 0x1105f8 usr_lr 0x119529
DEBUG:   [0x0] TEE-CORE:user_ta_enter:521: tee_user_ta_enter: TA panicked with code 0x0
DEBUG:   [0x0] TEE-CORE:tee_ta_invoke_command:561:   => Error: ffff3024 of 3
The code below fails at the 9th iteration.
TEE_Result ret;

TEE_ObjectHandle object = TEE_HANDLE_NULL;

int object_id = 0;
TEE_ObjectInfo info;

char write_data[50] = {0};
uint32_t write_data_len = 50;
char read_data[50] = {0};
uint32_t read_bytes;

uint32_t flags =  TEE_DATA_FLAG_ACCESS_WRITE | TEE_DATA_FLAG_ACCESS_READ;

int i = 1;
TEE_CreatePersistentObject(TEE_STORAGE_PRIVATE, &object_id, sizeof(int), flags, 
                           TEE_HANDLE_NULL, NULL, 0, &object);

while (i < 21) {

    IMSG("\n\nLOOP : %d", i);

    ret = TEE_SeekObjectData(object, 0, TEE_DATA_SEEK_SET);
    if (ret != TEE_SUCCESS) {
        EMSG("Seek failed : 0x%X", ret);
    }

    ret = TEE_WriteObjectData(object, write_data, write_data_len);
    if (ret != TEE_SUCCESS) {
        EMSG("Write failed : 0x%X", ret);
    }

    ret = TEE_SeekObjectData(object, 0, TEE_DATA_SEEK_SET);
    if (ret != TEE_SUCCESS) {
        EMSG("Seek failed : 0x%X", ret);
    }

    ret = TEE_ReadObjectData(object, read_data, write_data_len, &read_bytes);
    if (ret != TEE_SUCCESS) {
        EMSG("Read failed : 0x%X", ret);
    }

    i++;
}

The problem appears after a certain number of operations on the persistent object, for instance, if I add other operations like Read, Write or Seek, it will fail on one of these.

Output I obtain:
ERROR:   TEE-CORE: Can not open meta file
ERROR:   TEE-CORE: Failed to open TEE file
ERROR:   TEE-CORE: Object corrupt
[...]
ERROR:   TEE-CORE: ERROR:   USER-TA: Seek failed : 0xF0100001

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions