Home ยป Deciphering C/C++ Code to Rust: A Tale of Android Firmware Retrofitting Made Simple

Deciphering C/C++ Code to Rust: A Tale of Android Firmware Retrofitting Made Simple

Google has revealed details through the Google Security Blog about switching the Android firmware code from the original C/C++ to Rust to leverage the memory-safe feature at the language level.

Google started using Rust in Android since 2021 and has seen good results. In this case, Google says that changing the code from C/C++ to Rust directly as a drop-in replacement is something that can be realistically done at the firmware level.

Google states that firmware is a vulnerable point for easy attacks because firmware code often lacks the security systems used in higher-level software and is often filled with old C/C++ code that has been around for a long time. Solving this issue by changing the code to Rust, which can replace C without losing efficiency (no overhead), is a suitable solution.

The approach Google is using is to gradually switch from high-risk code segments first, by creating a layer that converts Rust APIs to the original C APIs. The problem encountered along the way is the need to convert Rust code that calls the std library (runs on full-fledged operating systems) into a no_std environment (runs on bare metal hardware in the case of firmware), which Google has detailed the technical solution in the blog.

Google describes the transition this time as “easy” and has benefited from memory safety while maintaining performance on par with C. Therefore, Google recommends other organizations looking to transition from old code in firmware to follow the path that Google has successfully traversed.

TLDR: Google is switching Android firmware code from C/C++ to Rust for better security and maintains performance without overhead, suggesting other organizations follow suit for success.

More Reading

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Unveiling the BOOX Note Air4 C and Note Max in A4 size, alongside the Palma 2 smartphone.

Google Contributes $1 Million Donation to Rust Foundation to Enhance Collaborative Efficiency with C++

Exploring Alternative Compilation Options with GCCRS Outside of Rust’s Primary Compiler