Skip to content

Cstr verify safety contracts of unsafe functions strlen, from_bytes_with_nul_unchecked - #193

Merged
carolynzech merged 39 commits into
model-checking:mainfrom
rajathkotyal:c-0013-rajathm-part3
Dec 12, 2024
Merged

carolynzech merged 39 commits into
model-checking:mainfrom
rajathkotyal:c-0013-rajathm-part3

Conversation

@rajathkotyal

@rajathkotyal rajathkotyal commented Nov 28, 2024 •

Copy link
Copy Markdown

Towards #150

Annotates and verifies the safety contracts for the following unsafe functions:

from_bytes_with_nul_uncheked core::ffi::c_str
strlen core::ffi::c_str

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

@rajathkotyal
rajathkotyal requested a review from a team as a code owner November 28, 2024 06:14
@rajathkotyal rajathkotyal changed the title C0013-Cstr verify safety contracts of unsafe functions Cstr verify safety contracts of unsafe functions from_ptr, strlen, from_bytes_with_nul_uncheked - Stubbing Nov 28, 2024
@rajathkotyal
rajathkotyal marked this pull request as draft November 28, 2024 09:54
Comment thread library/core/src/ffi/c_str.rs Resolved
Comment thread library/core/src/ffi/c_str.rs Resolved
Comment thread library/core/src/ffi/c_str.rs Resolved
Comment thread library/core/src/ffi/c_str.rs Resolved
@rajathkotyal rajathkotyal changed the title Cstr verify safety contracts of unsafe functions from_ptr, strlen, from_bytes_with_nul_uncheked - Stubbing Cstr verify safety contracts of unsafe functions strlen, from_bytes_with_nul_uncheked Dec 3, 2024
@rajathkotyal
rajathkotyal marked this pull request as ready for review December 3, 2024 02:30
Comment thread library/core/src/ffi/c_str.rs Resolved
Comment thread library/core/src/ffi/c_str.rs Resolved
Comment thread library/core/src/ffi/c_str.rs Resolved
@Yenyun035

Yenyun035 commented Dec 10, 2024 •

Copy link
Copy Markdown

That means we need to enable C-FFI support like #204

@celinval Got it. Thank you for mentioning that. This means #204 needs to be merged first.

Edit: I tried adding -Z c-ffi --output-format=old --no-assertion-reach-checks flags to run_kani.sh, it still failed with the same error.

@carolynzech

Copy link
Copy Markdown

@Yenyun035 can you fix the failing Rust tests and then we'll take a look if there's still issues?

@Yenyun035

Copy link
Copy Markdown

@carolynzech Sure. I annotated is_null_terminated helper function with #[cfg(kani)] now. I think it should fix the failed rust tests. If not, I'll try to figure out another solution.

Comment thread library/core/src/ffi/c_str.rs Resolved
github-merge-queue Bot pushed a commit that referenced this pull request Dec 11, 2024
Towards #150

Similar PR Ref : #193 

Annotates and verifies the safety contracts for the unsafe function :
`from_ptr` - `core::ffi::c_str`

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

---------

Co-authored-by: Yenyun035 <[email protected]>
Co-authored-by: Yenyun035 <[email protected]>
@tautschnig

Copy link
Copy Markdown
Member

@rajathkotyal Can I please ask you to resolve conflicts that arose with #204 now merged?

@Yenyun035

Copy link
Copy Markdown

@tautschnig Fixed. Thank you.

@carolynzech carolynzech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice!

@carolynzech carolynzech changed the title Cstr verify safety contracts of unsafe functions strlen, from_bytes_with_nul_uncheked Cstr verify safety contracts of unsafe functions strlen, from_bytes_with_nul_unchecked Dec 11, 2024
@rajathkotyal

Copy link
Copy Markdown
Author

Thanks @Yenyun035 !

@carolynzech
carolynzech added this pull request to the merge queue Dec 12, 2024
Merged via the queue into model-checking:main with commit eb21f69 Dec 12, 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.

5 participants