-
Notifications
You must be signed in to change notification settings - Fork 10
Audit bytes crate #6
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
Comments
I'm maybe a fourth of the way through auditing this, and should be done around Thursday or Friday. So far everything looks good, assuming that having access to uninitialized memory outside of an untagged union or raw pointer isn't UB (IIRC that's unclear). |
I think references to uninit are deadly right now. |
I believe that crate could also use a conversion to |
Apparently there is an issue in |
Yeah there's a huge comment on all the functions that knowingly take advantage of UB. IIRC (not at my computer so I can't see my draft report) the author missed annotating one case of the same sort of intentional, but (for now) correctly compiled UB. Also, sorry about not finishing the report yet. The only excuse I can offer is laziness. |
Correctly compiled on x86_64, at least. I imagine it would be miscompiled on, say, an Alpha AXP (which has an absurdly weak memory model), but Rust doesn't support those so who cares. |
Doesn't standard ARM have a weaker memory model? Because Rust compiles for that all the time. |
Yes the ARM memory model is weaker than x86's but it's not so weak as to require a barrier for relaxed reads, and I'm assuming that LLVM will do the same program-level optimizations independent of architecture (which may, admittedly, be a bad assumption). Anyways, here's the internals threads on intentional UB in bytes:
My observation on the soundness of bytes was premature. Admittedly, everything but |
This is an all-volunteer effort, so don't feel pressured to complete the audit. Just note what you've already looked at and what the results were so that someone else could pick up where you left off. |
Alright, seeing as I'm not sure if I'll ever get back to this (hopefully I will, but...), and I almost wiped my home directory1 and I didn't have this backed up. The incomplete report is here if somebody else wants to complete it, though I might resume work on it. Footnotes
|
FWIW, those annotations were added by me, not the original author. ;) Which case did I miss?
Do you remember at which types this happens? For integers (and raw poiners) it is unclear, for pretty much anything else it is fairly certain that uninitialized memory is UB.
No, references pointing to something are never worse than having the data by-value. |
The functions I saw potential issues with (again, didn't review all the unsafe functions, see my draft report) that hadn't been noted before were |
Thanks! Submitted tokio-rs/bytes#289. |
Another issue was discovered recently - a fairly obscure contract is violated: tokio-rs/bytes#328 Another issue was found by accidentally stumbling into a segfault: tokio-rs/bytes#340 and a related issue was later discovered by code analysis: tokio-rs/bytes#343 |
It seems all the issues described in the audit by @nuew above are fixed as of version 0.5.3:
Also |
I was mistaken about the |
Maybe we can start filing recently added unsound informational advisories to bugs listed here? |
Uh oh!
There was an error while loading. Please reload this page.
https://docs.rs/bytes/0.4.12/bytes/
Slice-like type with atomic reference counting on top. Insanely popular - 12,000 downloads/day. Used in
reqwest
,tokio-tcp
andhyper
, exposed to untrusted data from the network. Contains plenty of unsafe code.The text was updated successfully, but these errors were encountered: