Google says replacing C/C++ in firmware with Rust is easy
Google has transitioned firmware for protected virtual machines to Rust, enhancing security by addressing memory safety issues. Despite challenges, the U.S. government supports Rust adoption for improved software security.
Read original articleGoogle has recently transitioned the firmware for protected virtual machines in its Android Virtualization Framework from C/C++ to Rust, promoting the latter as a more secure alternative. In a detailed write-up, Android engineers Ivan Lozano and Dominik Maier highlighted the advantages of Rust, particularly its ability to mitigate memory safety issues such as buffer overflows and use-after-free vulnerabilities that are prevalent in C/C++ code. Despite Rust's benefits, the transition is complicated by the steep learning curve associated with the language and resistance from established C/C++ developers. The U.S. government and tech firms are increasingly advocating for the adoption of Rust to enhance software security, with the Cybersecurity & Infrastructure Security Agency recommending that vendors prioritize the elimination of memory safety vulnerabilities. Google has reported that its Rust developers are significantly more productive than their C++ counterparts and is committed to expanding Rust's use across its platforms, including Android and Chromium. The company aims to provide developers with the necessary resources and training to facilitate this transition, emphasizing Rust's role in building secure and reliable software.
- Google has rewritten firmware in Rust to enhance security.
- Rust is seen as a solution to memory safety issues common in C/C++.
- Transitioning to Rust faces challenges due to its learning curve and developer resistance.
- The U.S. government supports Rust adoption for improved software security.
- Google reports higher productivity from Rust developers compared to C++ engineers.
Related
Rust for Filesystems
At the 2024 Linux Summit, Wedson Almeida Filho and Kent Overstreet explored Rust for Linux filesystems. Rust's safety features offer benefits for kernel development, despite concerns about compatibility and adoption challenges.
Investing in Rust
Investing in Rust programming language can enhance cybersecurity by preventing memory-related vulnerabilities. Challenges in adoption include integration issues and skill set mismatches, suggesting U.S. policy interventions for promotion.
DARPA suggests turning old C code automatically into Rust – using AI, of course
DARPA is launching the TRACTOR project to automate converting legacy C code to Rust, addressing memory safety vulnerabilities. The initiative aims for high automation despite challenges in translating complex C constructs.
Linux-for-Rust or Rust-for-Linux
The integration of Rust into the Linux kernel faces skepticism over usability, performance, and support issues, while some developers advocate for its potential, citing successful implementations and the need for better compiler support.
Deploying Rust in Existing Firmware Codebases
Google's Android team is integrating Rust into firmware to enhance security, focusing on new and high-risk code while addressing compatibility and porting challenges with tools like Bindgen for seamless integration.
Not so. The actual study compared the cost of writing something in C++ to the cost of porting it to Rust.
The ultimate problem is that most of the muscle memory you’ve built using C over the years becomes useless when writing Rust due to so many of the semantic differences. If you were an expert and highly productive C programmer, your productivity will go out the window for what feels like a long time until you feel even just comfortable writing Rust. That makes Rust a very hard sell for C programmers who simply want to get things done. This is an area, by the way, that I think Zig does extremely well at—it provides safer semantics (despite its lack of guaranteed memory safety à la Rust) in a rather simple language and without rendering so much of your experience useless.
- Compile times. This, above all else.
- As an embedded dev: no_std is still rough around the edges, which the original Google blog post captured pretty well. They didn’t talk about PACs - the PAC paradigm also feels needlessly complicated - whoever wrote it really loves their zero-sized types and made it verbose to the point where the solution feels worse than the problem (at least to me) for things like using GPIO lines.
- Rust has a history of shipping serious bugs (see, floating point recently), and you basically have to constantly update your rust version. Not ideal for commercial products, which want stability.
- All of the RTOS options are also young. None of the major existing ones (e.x. FreeRTOS) support Rust natively. You’re not just asking people to learn the language, but start over on libraries and platform as well.
- The community is weird. If you don’t drink the koolaid you will be attacked.
Rust is constantly getting better, and the pain points of C impact real peoples lives in very real ways (security bugs that have led to people truly getting hurt), so Rust feels inevitable, but it’s still early days and pain.
Not sure who would do that or what the implications might be for replacing all the say Python code with cpp.
You would think distributing firmware and flashing would be routine; several vendors have shown me it isn't
Related
Rust for Filesystems
At the 2024 Linux Summit, Wedson Almeida Filho and Kent Overstreet explored Rust for Linux filesystems. Rust's safety features offer benefits for kernel development, despite concerns about compatibility and adoption challenges.
Investing in Rust
Investing in Rust programming language can enhance cybersecurity by preventing memory-related vulnerabilities. Challenges in adoption include integration issues and skill set mismatches, suggesting U.S. policy interventions for promotion.
DARPA suggests turning old C code automatically into Rust – using AI, of course
DARPA is launching the TRACTOR project to automate converting legacy C code to Rust, addressing memory safety vulnerabilities. The initiative aims for high automation despite challenges in translating complex C constructs.
Linux-for-Rust or Rust-for-Linux
The integration of Rust into the Linux kernel faces skepticism over usability, performance, and support issues, while some developers advocate for its potential, citing successful implementations and the need for better compiler support.
Deploying Rust in Existing Firmware Codebases
Google's Android team is integrating Rust into firmware to enhance security, focusing on new and high-risk code while addressing compatibility and porting challenges with tools like Bindgen for seamless integration.