Skip to content

Verify/ptr const slice type #4

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

Merged
merged 4 commits into from
Oct 3, 2024

Conversation

szlee118
Copy link
Collaborator

@szlee118 szlee118 commented Oct 3, 2024

Description:

This pull request introduces additional verification checks and contracts for raw pointer arithmetic in Rust using Kani. It implements preconditions and postconditions for the add and sub methods, ensuring safety when working with pointer offsets. Specifically, this includes:

  • Adding preconditions using kani::mem::can_dereference to validate that the pointer can be dereferenced before and after performing add and sub operations.
  • Implementing placeholder preconditions for further refinement (e.g., the valid range for count).
  • Adding verification functions (check_add_slice_i32, check_sub_slice_i32, and check_offset_slice_i32) to test these operations on slices of integers (i32).

Solution:

The solution addresses pointer arithmetic safety in Rust by leveraging Kani to perform formal verification. The add and sub functions for raw pointers are made safer by including verification annotations (#[requires] and #[ensures]) that check the validity of pointer dereferences. The tests ensure that these pointer operations are correctly modeled, catching any potential errors or invalid pointer usages.

This PR aims to resolve pointer arithmetic challenges by verifying behavior through formal proofs, adhering to safe coding practices in Rust's unsafe code blocks.


Resolves model-checking#74

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@szlee118 szlee118 merged commit 31532c9 into verify/ptr_const_offset Oct 3, 2024
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.

1 participant