Porting C to Rust for a Fast and Safe AV1 Media Decoder
memorysafety.org
memorysafety.org
For example in a similar translation there was UB here: https://gitlab.com/sequoia-pgp/sha1collisiondetection/-/comm...
And here: https://gitlab.com/sequoia-pgp/sha1collisiondetection/-/comm...
I thought there was a fancier/weirder programming error in that crate but I can't find it right now.
Well-engineered systems like Genode focus on this approach, leveraging capabilities.
Rust projects are much easier to build, especially when supporting multiple platforms. I've converted projects to Rust to make them easier to build and deploy.
> even the same ones.
Rust supports multiple versions of the same dependency, so that may be what you observed.
> these decoders are a dangerous source of bugs
Hm… I thought code in any language could be such “source.”
This is why Apple disables most codecs in iMessage in lockdown mode.
from the hyperlink you copied...
Rust's Memory Safety Model: An Evaluation of Its Effectiveness in Preventing Common Vulnerabilities: https://www.sciencedirect.com/science/article/pii/S187705092...
"...can Rust achieve the memory-safety promise? This paper studies the question by surveying 186 real-world bug reports collected from several origins which contain all existing Rust CVEs (common vulnerability and exposures) of memory-safety issues by 2020-12-31. We manually analyze each bug and extract their culprit patterns. Our analysis result shows that Rust can keep its promise that all memory-safety bugs require unsafe code..."
You can't change the environment codecs are expected to run in, or the data they are used to process, but you can use effective tools to limit the sorts of bugs you are likely to run into, and isolate them to the relatively small area between unsafe declarations. Exploitable C style memory errors simply aren't possible in memory safe languages like Python, for instance, but Python leaves performance on the table which is valuable for codecs. Rust provides a high degree of memory safety while performing as well as C or C++.
> obscure, opaque, diverse, highly privileged, largely untested, and highly exposed
In short, expressing this code in an appropriate language can absolutely address and even go some way toward correcting each of those issues.