Improve performance and language support of memory initialization checks#3313
Merged
artemagvanian merged 31 commits intomodel-checking:mainfrom Jul 12, 2024
Merged
Improve performance and language support of memory initialization checks#3313artemagvanian merged 31 commits intomodel-checking:mainfrom
artemagvanian merged 31 commits intomodel-checking:mainfrom
Conversation
97f1cbe to
0723510
Compare
Contributor
Author
|
Seems like |
celinval
reviewed
Jul 4, 2024
Contributor
celinval
left a comment
There was a problem hiding this comment.
I think it would be much simpler if you
zhassan-aws
reviewed
Jul 5, 2024
Contributor
zhassan-aws
left a comment
There was a problem hiding this comment.
Nice!
What happens if there are two accesses to distinct uninitialized memory in a row? Will the first violation block the reporting of the second?
Contributor
Author
Good question: I tested this simple case and all of the violations were reported. use std::ptr::addr_of;
#[repr(C)]
struct S(u32, u8);
/// Checks that Kani catches an attempt to access padding of a struct using raw pointers.
#[kani::proof]
fn check_uninit_padding() {
let s = S(0, 0);
let ptr: *const u8 = addr_of!(s) as *const u8;
let padding = unsafe { *(ptr.add(5)) }; // ~ERROR: padding bytes are uninitialized, so reading them is UB.
let padding_next = unsafe { *(ptr.add(6)) }; // ~ERROR: padding bytes are uninitialized, so reading them is UB.
inner_fn(ptr);
}
fn inner_fn(ptr: *const u8) {
let padding_inner = unsafe { *(ptr.add(7)) }; // ~ERROR: padding bytes are uninitialized, so reading them is UB.
} |
Contributor
Cool, thanks for checking. |
zhassan-aws
reviewed
Jul 10, 2024
Co-authored-by: Zyad Hassan <88045115+zhassan-aws@users.noreply.github.com>
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up PR for #3264, a part of the larger work towards #3300.
This PR introduces:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.