-
Notifications
You must be signed in to change notification settings - Fork 41
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
Challenge 1: Verify core
transmuting methods
#19
Comments
Can we have an explicit link to the challenge... |
core
transmuting methodscore
transmuting methods
Hi all, I'll be working on this alongside professor Patrick Lam (@patricklam) from the University of Waterloo. Will keep you updated on progress, and happy to collaborate with anyone else working on this! |
Hi, I just had some questions about verifying the (1) Which combinations of input/output types specifically would we want to check for
Does something like this seem reasonable for (2) Also, in the comments of #100, it's mentioned that it's better to have separate harnesses for different input types. In the case of Thank you! |
Hi @AlexLB99, answering your questions: (1) For the transmute challenge, I would suggest that you try difference layout combinations. For example, transmuting types with different sizes, types with zero size type, types with different validity requirements, with different padding bytes, as well as types with the same layout. |
I was reading the description, and the definition of soundness.
I was wondering if this definition includes the niche tag encoding for enums. Should it be interpreted as a case of bit-validity or as invariants on field's value? While I think challenges #109 and #84 are related as the basic cases of it, you can imagine more complicated possible undefined behaviors when transmuting to enums like below (which also uses a niche encoding because of enum Bar {
A,
B(Option<(u8, char)>),
C,
} BTW, we at SFU, would be happy to participate in these challenges under our project which is a tool performing concolic execution for MIR. |
Hi @momvart, yes, this challenge does include niche tag encoding as part of the bit validity specification. Generating an invalid tag is UB, and generating an invalid variant value is also UB. Let's say you transmute an array of |
Also, it's great to hear about SFU interest, @momvart. Please check the tool application process, and if you have further questions, please post them in the discussions. |
I would also highly recommend checking transmuting pointers, references, as well as structures with references. |
Yes, this was just the first step to check that we're on the right track.
…On Fri, Dec 6, 2024, 8:50 AM Celina G. Val ***@***.***> wrote:
I would also highly recommend checking transmuting pointers, references,
as well as structures with references.
—
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOKE5WNLBQCJTPWQRU672D2ECU7HAVCNFSM6AAAAABJGDFVA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMRRGI3DGNZYGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi, I am a PhD student at The Chinese University of Hong Kong, and I'm interested in addressing this challenge. After some research, I believe a straightforward way to annotate safety contracts for |
Hi,
Interesting observation. It's hard for me to imagine being able to use
experimental traits in a proof of these methods, since they don't exactly
come with guarantees.
…On Mon, Dec 9, 2024 at 10:31 PM Kynehc ***@***.***> wrote:
Hi, I am a PhD student at The Chinese University of Hong Kong, and I'm
interested in addressing this challenge. After some research, I believe a
straightforward way to annotate safety contracts for transmute is by
using the unstable Transmutability trait. We need to ensure that the Dst
type implements the TransmuteFrom<Src> trait. However, it seems there's
no way to express this requirement with a predicate like #[requires(Dst:
TransmuteFrom<Src>)]. Could Kani potentially offer a method to achieve
this? Or is there something I might have overlooked?
—
Reply to this email directly, view it on GitHub
<#19 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOKE5VZKAVFKLLT5OZJQNL2EVPPLAVCNFSM6AAAAABJGDFVA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMRXGM4TCMZWGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This is a draft pull request towards solving #19. ## Changes - Added wrappers for `transmute_unchecked()` - Annotated these wrappers with contracts - Wrote harnesses that verify these wrappers Note: the reason we write wrappers for `transmute_unchecked()` and we annotate those wrappers is that function contracts do not appear to be currently supported for compiler intrinsics (as discussed in [rust-lang#3345](model-checking/kani#3345)). Also, rather than using a single wrapper for `transmute_unchecked()`, we write several with different constraints on the input (since leaving the function parameters completely generic severely restricts what we can do in the contracts, e.g., testing for equality). This is not intended to be a complete solution for verifying `transmute_unchecked()`, but instead a proof of concept to see how aligned this is with the expected solution. Any feedback would be greatly appreciated -- thank you! 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: AlexLB99 <[email protected]>
Hello, so for part 1 of this challenge (annotating the transmute intrinsics), we've prepared a document going over potential sources of UB and discussing if we cover these, and if not, why we don't. The main idea is that if we're only concerned in part 1 with preventing immediate UB, then the main thing to watch out for is value validity. Most of the other types of UB occur once the value produced by the transmute is used in some way (e.g., an invalid pointer). I was hoping to hear your thoughts on this -- do you believe that the transmute intrinsics should have function contracts that prevent/catch problematic cases but that aren't immediate UB (e.g., creating invalid pointers)? If not, do you see anything beyond value validity that can and should be encoded in a Kani function contract for transmute? If you have some time, please let me know what you think about this (@celinval, @feliperodri, or anyone else interested) -- thanks! 😃 Note: just to clarify, these questions are about the function annotations in particular-- as for harnesses, we definitely plan on adding some more in our next pr (e.g., for compound types and references). |
This issue is a tracking issue for Challenge 1: Verify
core
transmuting methods.Challenge link: https://model-checking.github.io/verify-rust-std/challenges/0001-core-transmutation.html
The text was updated successfully, but these errors were encountered: