Skip to content

Commit

Permalink
core: RPMB FS: nullify fops when resetting an enumerator
Browse files Browse the repository at this point in the history
According to the GP spec, TEE_ResetPersistentObjectEnumerator() "resets
an object enumerator handle to its initial state after allocation".
Therefore, syscall_storage_reset_enum() should set e->fops = NULL.

This fixes a regression introduced when the FOP interface was reworked.
I'm not simply reverting the return code from TEE_ERROR_GENERIC back to
TEE_ERROR_ITEM_NOT_FOUND, because the new code makes sense and it is
more sane to properly reset the state of the enumerator.

Consequently, tee_svc_close_enum() is updated to accept e->fops == NULL
which is valid when the enum has just been allocated or reset but not
started. We should not return an error status in this case.

Tested on HiKey using xtest with GP tests (all 3 filesystems: REE, SQL,
RPMB).

Fixes: b86c18e ("core: RPMB FS: prepare for new FOP interface")
Fixes: OP-TEE#1332
Signed-off-by: Jerome Forissier <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
  • Loading branch information
jforissier committed Feb 3, 2017
1 parent 8f07fe6 commit 928468c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/tee/tee_svc_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ static TEE_Result tee_svc_close_enum(struct user_ta_ctx *utc,

TAILQ_REMOVE(&utc->storage_enums, e, link);

if (!e->fops)
return TEE_ERROR_ITEM_NOT_FOUND;
if (e->fops)
e->fops->closedir(e->dir);

e->fops->closedir(e->dir);
e->dir = NULL;
e->fops = NULL;

Expand Down Expand Up @@ -845,6 +844,7 @@ TEE_Result syscall_storage_reset_enum(unsigned long obj_enum)
return res;

e->fops->closedir(e->dir);
e->fops = NULL;
e->dir = NULL;

return TEE_SUCCESS;
Expand Down

0 comments on commit 928468c

Please sign in to comment.