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

Check possible overflow in aot memory boundary check #3920

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

TianlongLiang
Copy link
Contributor

No description provided.

BUILD_OP(Add, offset_const, addr, offset1, "offset1");

if (is_target_64bit && comp_ctx->enable_bound_check) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Only when the memory is 64-bit (is_memory64 is true and target must be 64-bit) should we check the integer overflow: if memory is 32-bit, (1) if target is 32-bit, offset_const and addr are not extended to uint64, but integer overflow will be checked later, (2) if target is 64-bit, offset_const and addr are extended to uint64 and are no larger than UINT32_MAX, so integer overflow won't occur when adding them (the result is smaller than 8GB).

So how about if (is_memory64 && comp_ctx->enable_bound_check) {?

BUILD_OP(Add, offset, bytes, max_addr, "max_addr");

if (is_target_64bit && comp_ctx->enable_bound_check) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, if the memory is 32-bit, here offset and bytes are already extended to u64, adding them won't lead to integer overflow. Had better change to if (is_memory64 && comp_ctx->enable_bound_check)?

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.

2 participants