-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Secure Storage: storage size is not updated after TEE_TruncateObjectData #2094
Comments
Yes.
My understanding is that if the truncate operation changes only
Such a modification should definitely be added to |
When an object is truncated but the number of blocks is unchanged, only the metadata's length field is modified. The hash tree layer has to be notified so that it knows it has to flush the data before closing the object, otherwise the truncation is lost. Add a function for that purpose: tee_fs_htree_meta_set_dirty(), and call it whenever meta->length is updated. Fixes: OP-TEE#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
When an object is truncated but the number of blocks is unchanged, only the metadata's length field is modified. The hash tree layer has to be notified so that it knows it has to flush the data before closing the object, otherwise the truncation is lost. Add a function for that purpose: tee_fs_htree_meta_set_dirty(), and call it whenever meta->length is updated. Fixes: OP-TEE#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
When an object is truncated but the number of blocks is unchanged, only the metadata's length field is modified. The hash tree layer has to be notified so that it knows it has to flush the data before closing the object, otherwise the truncation is lost. Add a function for that purpose: tee_fs_htree_meta_set_dirty(), and call it whenever meta->length is updated. Fixes: OP-TEE#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
@kevin-peng-hao does #2099 fix the problem? |
@jforissier No, it doesn't. Actual if the new truncate size is larger than the old size, it works fine. |
@kevin-peng-hao can you share a patch for |
Sure. BTW, actually neither truncate or extend works if close & reopen. Sorry for the wrong conclusion earlier. The patch is based on optee_test release 2.6.0
|
Update regression test 6007 to close and re-open the persistent object. Reproducer for issue OP-TEE/optee_os#2094. From: Kevin Peng <kevinp@marvell.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Update regression test 6007 to close and re-open the persistent object after truncation and extension. Reproducer for issue OP-TEE/optee_os#2094. From: Kevin Peng <kevinp@marvell.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Hi @jforissier Any updates on this issue? |
Hi @kevin-peng-hao, I'm looking at this too. I have one additional fix. I have a pretty good idea of what more needs to be done, but since it's not complete yet I don't know if it's enough. |
Thanks, Jens @jenswi-linaro . Glad to know you guys are working on it. Thanks. |
When an object is truncated but the number of blocks is unchanged, only the metadata's length field is modified. The hash tree layer has to be notified so that it knows it has to flush the data before closing the object, otherwise the truncation is lost. Add a function for that purpose: tee_fs_htree_meta_set_dirty(), and call it whenever meta->length is updated. Fixes: OP-TEE#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
@kevin-peng-hao can you test again with #2099? Should be OK now. |
Update regression test 6007 to close and re-open the persistent object after truncation and extension. Reproducer for issue OP-TEE/optee_os#2094. From: Kevin Peng <kevinp@marvell.com> [jf: add close/open to test_file_hole(), too] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Thanks @jforissier It's been fixed. |
@kevin-peng-hao yes, I will merge the fix (2099) and the |
Great, thanks. @jforissier |
Includes the meta data when calculating the hash of the root node to detect changes in file length while number of blocks is unchanged. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Fixes: OP-TEE#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Tested-by: Kevin Peng <kevinp@marvell.com> [jf: add Fixes:, Reported-by: and Tested-by: tags] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Includes the meta data when calculating the hash of the root node to detect changes in file length while number of blocks is unchanged. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Fixes: OP-TEE#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Tested-by: Kevin Peng <kevinp@marvell.com> [jf: add Fixes:, Reported-by: and Tested-by: tags] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Update regression test 6007 to close and re-open the persistent object after truncation and extension. Reproducer for issue OP-TEE/optee_os#2094. Suggested-by: Kevin Peng <kevinp@marvell.com> [jf: add close/open to test_file_hole(), too] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Update regression test 6007 to close and re-open the persistent object after truncation and extension. Reproducer for issue OP-TEE/optee_os#2094. Suggested-by: Kevin Peng <kevinp@marvell.com> [jf: add close/open to test_file_hole(), too] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Includes the meta data when calculating the hash of the root node to detect changes in file length while number of blocks is unchanged. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Fixes: OP-TEE/optee_os#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Tested-by: Kevin Peng <kevinp@marvell.com> [jf: add Fixes:, Reported-by: and Tested-by: tags] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Includes the meta data when calculating the hash of the root node to detect changes in file length while number of blocks is unchanged. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org> Fixes: OP-TEE/optee_os#2094 Reported-by: Kevin Peng <kevinp@marvell.com> Tested-by: Kevin Peng <kevinp@marvell.com> [jf: add Fixes:, Reported-by: and Tested-by: tags] Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
I’m working with the OP-TEE release 2.6.0.
But I found that the
TEE_TruncateObjectData
does not behave as expected:The truncated size is not write to storage meta.
To be more detailed:
So probably the truncated size is not saved to the storage, and when the object is reopened and the data size read is the old one.
We also found some test cases about
TEE_TruncateObjectData
, but it doesn't close and reopen the object. If we modified the case to that it close the object and open it and then read it, we got the same result.I traced the code to
ree_fs_truncate()
intee_ree_fs.c
and did find some bugs:The if (!res) should be if (res), right?
But this is only the part of the issue. The
tee_fs_htree_sync_to_storage
still didn't sync the data size to storage, because!ht->dirty
:I'm somehow not allowed to go deep further.
So I raised the issue here.
Thanks,
Kevin
The text was updated successfully, but these errors were encountered: