-
Notifications
You must be signed in to change notification settings - Fork 347
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
-Zmiri-strict-provenance reports UB when using the address-exposing Strict Provenance APIs correctly #2134
Comments
Quoting the from_exposed_addr docs:
So I think this is intended behavior. However, after #2059 landed I want to add a warning (or maybe even an error?) so Miri in strict provenance mode says, the first time |
Also see #2133 which I literally wrote in parallel with you writing this. ;) |
Is there a way to invoke miri such that the distinction between these two APIs is actually useful? i.e. such that it attempts to be strict but incorporates exposing and from_exposed_addr as an operation? I forget, is angelic nondet a nightmare to actually support in an interpretter? |
Not yet, but see #2133 for the plan to make that happen. :D My plan is to make that the default, and make Yes, angelic is a nightmare, so this mode will miss some bugs where you use a |
make ptr::invalid not the same as a regular int2ptr cast In Miri, we would like to distinguish `ptr::invalid` from `ptr::from_exposed_provenance`, so that we can provide better diagnostics issues like rust-lang/miri#2134, and so that we can detect the UB in programs like ```rust fn main() { let x = 0u8; let original_ptr = &x as *const u8; let addr = original_ptr.expose_addr(); let new_ptr: *const u8 = core::ptr::invalid(addr); unsafe { dbg!(*new_ptr); } } ``` To achieve that, the two functions need to have different implementations. Currently, both are just `as` casts. We *could* add an intrinsic for this, but it turns out `transmute` already has the right behavior, at least as far as Miri is concerned. So I propose we just use that. Cc `@Gankra`
I will close this in favor of #2133. Currently this is intended behavior, and eventually the plan is that Miri would already error in the |
make ptr::invalid not the same as a regular int2ptr cast In Miri, we would like to distinguish `ptr::invalid` from `ptr::from_exposed_provenance`, so that we can provide better diagnostics issues like rust-lang/miri#2134, and so that we can detect the UB in programs like ```rust fn main() { let x = 0u8; let original_ptr = &x as *const u8; let addr = original_ptr.expose_addr(); let new_ptr: *const u8 = core::ptr::invalid(addr); unsafe { dbg!(*new_ptr); } } ``` To achieve that, the two functions need to have different implementations. Currently, both are just `as` casts. We *could* add an intrinsic for this, but it turns out `transmute` already has the right behavior, at least as far as Miri is concerned. So I propose we just use that. Cc `@Gankra`
I understand why this happens, but this is if nothing else incredibly surprising for users. The intuition is that the Strict Provenance mode in Miri should be compatible with the Strict Provenance APIs in the standard library. Could we make that happen? Or will this just be closed by the permissive provenance work?
The text was updated successfully, but these errors were encountered: