-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
UB in IoReader::fill_buffer #260
Comments
I think we need to handle the read_exact failure exposing uninitialized bytes. I think the best way to do so is to pass a I think without rust-lang/rust#42788 (or whatever end result comes from that), we should just document that we expect |
I agree with the suggestion from the previous comment. We would accept a pull request implementing that strategy. |
This could probably be unpinned now as the issue is closed. |
Well, as stated, the current code may still exhibit UB. I also don't see the current “requirements” (putting this in quotes as safe functions may not make such requirements) documented in a place a user would find. |
It might be more trouble than it's worth to library consumers, but I think you could resolve the soundness issue by marking To avoid then needing to litter |
Do we have any benchmarks of what it costs to zero the buffer? Since we're reusing the buffer we won't have to zero it on every single invocation of fill_buffer, we only have to zero newly allocated bytes. |
Exposing uninitialized bytes and either leaking them to the outside world or using them in place of data is a potential security vulnerability. Please file a security advisory at https://github.com/RustSec/advisory-db so that anyone interested could get notified about this and upgrade to a version with the fix. |
While doing an unsafe-audit of bincode, I found this code in
src/de/read.rs
:If read_exact errors, this code might leave temp_buffer longer than the number of initialized bytes. Also, passing uninitialized memory to read_exact is UB. Since
read_exact
is a safe fn, any slice that's passed in must be initialized.From @rkruppe on Zulip:
The text was updated successfully, but these errors were encountered: