-
Notifications
You must be signed in to change notification settings - Fork 76
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
arr!
unsoundness
#98
Comments
Hmm. This is more problematic than I expected. What's happening is that unsafe { transmute::<[&A; 1], GenericArray<&A, 1>>([a]) } and then the lifetimes are filled in on either side of the transmute using What I need to figure out is how to ensure For example, type T = $T;
unsafe { transmute::<[T; 1], GenericArray<T, 1>>([a]) } ensures that the input and output element types are the exact same, including lifetimes. However, it disables lifetime elusion entirely, so no structs with lifetimes can be passed unless the type includes the (often anonymous) lifetime. So that's a no-go. Furthermore, because const-generics aren't a thing yet, or else this library wouldn't still be used, I cannot perform the transmute within a closed-form function that would otherwise ensure the input and output element types are the same. |
Heads up: this issue has been included in the RustSec advisory database. It will be surfaced by tools such as cargo-audit or cargo-deny from now on for affected versions of this crate. |
Still working on 0.8.4 (0.8.3 is also vulnerable), but it looks like crates.io is having some DNS issues (can't resolve static.crates.io... or is it just me?). EDIT: Nevermind, looks like it was just me. I switched to different DNS servers and managed to push 0.8.4, too. |
@fizyk20 Looks good to me! Thank you! |
PSA: Now that the fix has been backported to all affected release branches, anyone affected by this can fix it by running:
If your dependencies use multiple versions of
|
2601: chore(deps): bump generic-array from 0.12.3 to 0.12.4 to fix RUSTSEC-2020-0146 r=quake,zhangsoledad a=yangby-cryptape ### References - [RUSTSEC-2020-0146: generic-array: arr! macro erases lifetimes](https://rustsec.org/advisories/RUSTSEC-2020-0146) - [`generic-array` Issue-98: `arr!` unsoundness](fizyk20/generic-array#98) - [ChangeLog for `generic-array` from 0.12.3 to 0.12.4](fizyk20/generic-array@1e96864...42843cd) Co-authored-by: Boyu Yang <yangby@cryptape.com>
The
arr!
macro silently and unsoundly extends arbitrary lifetimes to'static
(playground):The text was updated successfully, but these errors were encountered: