-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Kani reject casts between mutable pointers of different padding
- Loading branch information
1 parent
fcc9d8b
commit 5e97cd3
Showing
4 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/// Checks that Kani rejects mutable pointer casts between types of different padding. | ||
#[kani::proof] | ||
fn invalid_value() { | ||
unsafe { | ||
let mut value: u128 = 0; | ||
let ptr = &mut value as *mut _ as *mut (u8, u32, u64); | ||
*ptr = (4, 4, 4); // This assignment itself does not cause UB... | ||
let c: u128 = value; // ...but this reads a padding value! ⚠️ | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Failed Checks: Kani does not support reasoning about memory initialization in presence of mutable raw pointer casts that could cause delayed UB. | ||
|
||
VERIFICATION:- FAILED | ||
|
||
Complete - 0 successfully verified harnesses, 1 failures, 1 total. |