Skip to content

Verify/ptr const slice type#4

Merged
szlee118 merged 4 commits into
verify/ptr_const_offsetfrom
verify/ptr_const_slice_type
Oct 3, 2024
Merged

Verify/ptr const slice type#4
szlee118 merged 4 commits into
verify/ptr_const_offsetfrom
verify/ptr_const_slice_type

Conversation

@szlee118

@szlee118 szlee118 commented Oct 3, 2024

Copy link
Copy Markdown
Collaborator

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