Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ta: pkcs11: write db_main and db_objs in one operation
Problem: There is a potential issue in persistent_token.c::init_persistent_db(). There are two steps to initialize a token DB if it doesn’t exist: 1. Call TEE_CreatePersistentObject() with db_main as the initial data. 2. 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. OP-TEE#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(). Tested-by: Weizhao Jiang <weizhaoj@amazon.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Signed-off-by: Weizhao Jiang <weizhaoj@amazon.com>
- Loading branch information