Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent objects : save informations after close #912

Closed
wants to merge 3 commits into from

Conversation

hoihochan
Copy link

When persistent objects are created, a header is written
into storage with its sizes. However, if additional data
is written into the persistent object, the header is not
updated properly

This fix adds a new pointer to save a copy of the header
in struct tee_pobj when it is opened or created. If
additional data is written during TEE_WriteObjectData call,
it will re-update the header in storage

Signed-off-by: Hoi-Ho Chan [email protected]

When persistent objects are created, a header is written
into storage with its sizes. However, if additional data
is written into the persistent object, the header is not
updated properly

This fix adds a new pointer to save a copy of the header
in struct tee_pobj when it is opened or created. If
additional data is written during TEE_WriteObjectData call,
it will re-update the header in storage

Signed-off-by: Hoi-Ho Chan <[email protected]>
@hoihochan
Copy link
Author

I think I need to add some error checks at the lseek calls

@@ -117,6 +117,7 @@ TEE_Result tee_pobj_get(TEE_UUID *uuid, void *obj_id, uint32_t obj_id_len,
o->refcnt = 1;
memcpy(&o->uuid, uuid, sizeof(TEE_UUID));
o->flags = flags;
o->head = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o->head i s already zero.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

@hoihochan
Copy link
Author

I fixed all the changes now. What is the appropriate git command to update the pull commit after I amended my local commit?

GitHub desktop didn't have the option...

When persistent objects are created, a header is written
into storage with its sizes. However, if additional data
is written into the persistent object, the header is not
updated properly

This fix adds a new pointer to save a copy of the header
in struct tee_pobj when it is opened or created. If
additional data is written during TEE_WriteObjectData call,
it will re-update the header in storage

Signed-off-by: Hoi-Ho Chan <[email protected]>
@vchong
Copy link
Contributor

vchong commented Jul 14, 2016

@hoihochan Once all reviewers are satisfied with your changes and have added their Reviewed-by tags, you need to:

  1. Rebase your changes on top of the latest code
  2. Squash all your commits into a single commit. The exception for this is if you have a big pull request that makes more sense to be separated into multiple commits.
  3. Add the Reviewed-by tags to your commit message
  4. Add a comment here saying that you've done 1-3 above

goto exit;
}

if (o->pobj->fops->write(&res, o->fd, head,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The coding style seems not as the same as optee here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a template I can follow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just take the code they have already wrote as a template.

@etienne-lms
Copy link
Contributor

try a simplified version. no head malloc.
If o->info.dataSize has to be updated, at end of syscall_storage_obj_write():

  • save obj offset, seek to 0, read head into a local structure
  • update local head.ds_size
  • write back the head, restore obj offset.

For security concerns, syscall_storage_obj_write() shall fail if head read from file as a wrong head magic.

@jbech-linaro
Copy link
Contributor

I'm going to close this PR, since a) there is no activity here and b) another fix has been submitted in #1217.

@ghost ghost closed this Dec 19, 2016
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants