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

src/interpreter.rs: Use wrapping_offset() for load/store operations #117

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

qmonnet
Copy link
Owner

@qmonnet qmonnet commented Oct 29, 2024

Rust 1.83 introduces some additional out-of-bound checks, making it illegal to attempt to load at an out-of-bound access when trying to load/store values from/to register in rbpf's interpreter, and causing the program to panick even before we reach the safety checks from check_mem().

I understand we need to use wrapping_offset() rather than offset() in that case, which causes the operation itself (but not the resulting poitner) to be safe, and the checked to be deferred. See also the related GitHub issue.

Fixes: #115

Rust 1.83 introduces some additional out-of-bound checks [0], making it
illegal to attempt to load at an out-of-bound access when trying to
load/store values from/to register in rbpf's interpreter, and causing
the program to panick even before we reach the safety checks from
check_mem().

I understand we need to use wrapping_offset() rather than offset() in
that case, which causes the operation itself (but not the resulting
poitner) to be safe, and the checked to be deferred. See also the
related GitHub issue [1].

[0] rust-lang/rust#130251
[1] #115

Reported-by: Ben Kimock <[email protected]>
Signed-off-by: Quentin Monnet <[email protected]>
@qmonnet qmonnet merged commit cfb363c into main Oct 29, 2024
8 checks passed
@qmonnet qmonnet deleted the pr/wrapping_offset branch October 29, 2024 13:14
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.

test_vm_stdw_add_overflow encounters UB, will fail in Rust 1.83
1 participant