跪拜 Guibai
← All articles
Android · Rust

Rust Takes Over Android Binder: 11,470 Lines of C Removed from Linux

By RockByte ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The swap means future Binder security fixes are written in a language that catches a class of memory-corruption bugs at compile time, reducing the risk of use-after-free and buffer overflows in Android's IPC layer. It also signals that a mature Rust implementation can take over a core kernel subsystem without sacrificing performance or compatibility.

Summary

Android's Binder driver, the kernel mechanism that handles inter-process communication between apps and system services, is moving from C to Rust. The Linux 7.4 development cycle has merged a patch that deletes the 11,470-line C implementation and switches the kernel build to the Rust version. Google plans to focus all future Binder development on the Rust code.

The Rust driver spent years reaching functional parity with C. In tests it matches or sometimes beats the C implementation on performance, and it has been in the mainline kernel since before the C driver was retired. Google engineer Carlos Llamas cited the growing difficulty of maintaining the C code without introducing bugs as the reason for the removal. The change eliminates the need to maintain two parallel implementations, so fixes and new features go into a single codebase.

The switch does not turn Android into a Rust system. Android still runs enormous amounts of C and C++, and Linux remains a multi-language project. Binder is one important component, and its move to Rust is a concrete sign that Rust has crossed from experimental to production in a security-sensitive, performance-critical kernel driver.

Takeaways
— Linux 7.4 removes the C implementation of the Android Binder driver, replacing it with a Rust version.
— The removal patch deletes 11,470 lines across 20 files, including more than 7,000 from binder.c.
— Google will focus future Binder development on the Rust implementation.
— The Rust driver has reached functional parity with C and, in some tests, matches or exceeds C performance.
— The Rust version spent several years in development and was merged into mainline before the C driver was removed.
— The change ends the burden of maintaining two separate implementations of the same driver.
— The C driver became harder to maintain as complexity grew; Google engineer Carlos Llamas cited this in the removal patch.
Conclusions

Replacing a long-lived C driver in a widely deployed kernel component is a stronger endorsement of Rust than any feature announcement, because the Rust version had to prove parity, performance, and maintainability over years.

The performance claim is workload-specific: it says Rust matches or beats C in the tests used, not that Rust is universally faster.

Android will not become a Rust project; the move applies to Binder only, and other subsystems will be judged on their own requirements and maintainer capacity.

The removal patch is a practical argument for evaluating language changes based on maintenance costs and feature requirements, not language popularity.

Concepts & terms
Binder
Android's core inter-process communication (IPC) mechanism. The Binder driver in the Linux kernel coordinates transactions between apps and system services that run in separate address spaces.
IPC (inter-process communication)
A controlled mechanism that lets processes exchange data and requests without directly accessing each other's memory.
Memory safety
The property of a program that prevents certain classes of bugs, such as use-after-free, buffer overflows, and dangling pointers, typically by enforcing rules about object lifetimes and bounds.
Rust ownership and borrowing
Rust's compile-time rules that govern when memory can be read, written, or freed. They prevent many memory safety errors in safe code without a garbage collector.
Functional parity
The new Rust implementation supports all the features of the old C implementation that Android depends on, so it can be a drop-in replacement.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗