core: tee_ree_fs: fix handling of large file offsets - #7925
Merged
Conversation
Contributor
Author
|
This solves issues similar to those addressed in OP-TEE/optee_client#422 |
jenswikl
reviewed
Aug 13, 2026
ysbnim
force-pushed
the
fix_ree_fs
branch
2 times, most recently
from
August 14, 2026 05:09
2f7df9d to
5f50be6
Compare
Contributor
|
|
REE FS supports file positions up to TEE_DATA_MAX_POSITION (0xffffffff), but pos_to_block_num() accepted int. Positions above INT_MAX (0x7fffffff) were narrowed when converted to block numbers. Use size_t for the conversion and block numbers in the read and write paths. Fixes: a238b74 ("core: REE FS: use the new hash tree interface") Signed-off-by: Sungbae Yoo <sungbaey@nvidia.com> Reviewed-by: Jens Wiklander <jens.wiklander@oss.qualcomm.com>
REE FS backing file offsets can exceed 4 GiB within the valid logical position range. However, get_offs_size() stored physical offsets in size_t. On 32-bit builds, offsets above SIZE_MAX (0xffffffff) therefore wrapped before being passed to the 64-bit read and write RPC interface. The truncate length could wrap in the same way. Calculate physical offsets with 64-bit arithmetic and carry them as tee_fs_off_t through read, write, and truncate RPC requests. Fixes: a238b74 ("core: REE FS: use the new hash tree interface") Signed-off-by: Sungbae Yoo <sungbaey@nvidia.com> Reviewed-by: Jens Wiklander <jens.wiklander@oss.qualcomm.com>
Contributor
Author
|
Gentle reminder. Attached reviewed-by tags. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ensures that REE FS handles large files correctly on both 32-bit and 64-bit builds.
On 64-bit builds, logical file positions above INT_MAX exceeded the range of int used by pos_to_block_num(), causing incorrect block numbers. Use size_t for file position and block number calculations.
On 32-bit builds, physical backing file offsets above 4 GiB exceeded the range of size_t and wrapped around. Calculate these offsets using 64-bit arithmetic and carry them as tee_fs_off_t through the read, write, and truncate RPC interfaces.