Rust doesn’t have a sluggish rubbish collector. Instead, it makes use of a mechanism known as the borrow checker that ensures reminiscence security at compile time. This strict algorithm ensures you can’t “forget” to liberate reminiscence—code merely gained’t compile if the reminiscence guidelines are breached. This is what makes Rust a memory-safe language.
However, not even Google can wave its proverbial hand and alter how modem firmware is written—we’re speaking about tens of megabytes of executable machine code, which is so much. Not solely wouldn’t it be a herculean activity to replace many years of labor, however lots of the corporations concerned additionally take into account the inside workings of modems to be commerce secrets and techniques.
To defend the (*10*) modem from zero-day assaults, Google targeted on the DNS parser. As mobile options have migrated to knowledge networks, DNS has change into a core a part of how telephones work. Google explains that DNS requires parsing of untrusted knowledge, and that makes it a significant safety concern, but it surely’s one you possibly can resolve with Rust.
Google selected the hickory-proto open supply Rust DNS library, which isn’t significantly optimized however has broad adoption and assist. The modem in (*10*) telephones isn’t a memory-constrained surroundings, which allowed the group to tack on a Rust part to make DNS within the present code safer. The group stripped out the usual library dependencies, permitting it to compile to machine code for sooner operation, which was then grafted onto the prevailing C/C++ modem code. In whole, the Rust parts added 371KB, which is workable within the (*10*) modem.
Under this method, any try to set off a vulnerability by manipulating reminiscence runs into the Rust wall—it could actually’t be affected by malicious DNS packets. The (*10*) 10 telephones are the primary to ship with this safer modem implementation. Google hopes this work will enable different platforms to make comparable enhancements, however the firm notes the dimensions of its chosen Rust library could possibly be an issue for less complicated embedded techniques. It could also be attainable to deal with that by making the library extra modular sooner or later. Google additionally sees this work as a basis for integrating extra memory-safe parts into the mobile baseband in time.