Problem:
There is a potenssial issue in persistent_token.c::init_persistent_db(). There are two steps to initialize a token db if it doesn’t exist:
Call TEE_CreatePersistentObject() with db_main as the initial data.
Truncate the object data and then insert db_obj data. If a power loss occurs between above two steps, only the db_main data is present in the database. When the device restarts, it detects the existing database and successfully reads db_main, but fails to read db_obj, leading to a TA panic each time.
https://github.com/OP-TEE/optee_os/issues/6977
Solution:
Write both db_main and the initial 4 bytes of db_objs (with a count of 0) in a single operation during TEE_CreatePersistentObject().
Problem: There is a potenssial issue in persistent_token.c::init_persistent_db(). There are two steps to initialize a token db if it doesn’t exist:
Solution: Write both db_main and the initial 4 bytes of db_objs (with a count of 0) in a single operation during TEE_CreatePersistentObject().
Tested-by: Weizhao Jiang weizhaoj@amazon.com