Urgent.News

What's breaking now, across thousands of outlets.

Tech

Removing binder.c

The final talk at Kangrejos 2026 featured a discussion on the removal of the C implementation of Android's Binder driver, the primary interprocess communication mechanism used on Android devices. Carlos Llamas announced the deletion of the C code, which was met with applause from the audience. Alice Ryhl, who has been working on the Rust implementation for several years, provided insights into the challenges and complexities involved in the transition.

Binder was introduced to the kernel in 2008 as an interprocess communication mechanism for Android devices, drawing inspiration from the BeOS design. Over time, it has evolved significantly, offering a comprehensive set of operations for efficient process communication with minimal overhead. However, this functionality also presents a large attack surface, making it a frequent target for complex chained attacks against Android, as highlighted by Llamas.

Google's internal red team identified Binder as the most vulnerability-dense component in the entire operating system, with an unusually high number of CVEs per line of code.

The transition to the Rust implementation began in 2021, with the first publicly posted version released in 2023. The effort took over five years to complete, given the extensive usage of Binder across Android devices, which number more than three billion. Binder handles critical processes such as screen touches, permission checks, and cross-application messages, resulting in hundreds of billions of transactions per second globally.

This scale necessitated meticulous attention to performance, particularly tail latencies that can significantly impact user experience.

One of the most challenging aspects of the transition was maintaining performance parity between the C and Rust implementations, especially in low-latency scenarios such as screen rendering. While the core algorithms remained identical, differences in how the C and Rust languages handle locking mechanisms led to performance issues.

Ryhl addressed these by minimizing operations under locks and replacing mutexes with spinlocks, thereby eliminating priority inversion problems. The Rust implementation, while initially slower due to its complexity, eventually outperformed the C version after Ryhl introduced an algorithmic improvement that reduced the number of required system calls.

Another significant challenge was managing tracepoints, which are kernel-internal debugging tools that users inadvertently rely on. Ryhl had to replicate existing tracepoints in the Rust implementation to ensure compatibility, which also extended to certain data structures crucial for driver functionality. Additionally, the Rust code had to accommodate various kernel security features like address-space layout randomization (KASLR), control-flow integrity (CFI), and profile-guided optimization, which are standard in production Android kernels but introduce complexities in code generation.

The removal of the C implementation necessitates a phased deployment plan to transition users to the Rust version. However, this process is complicated by vendor-specific hooks embedded in the C implementation, which are not easily replicated in the Rust version. Android vendors will continue using the C Binder for some time, receiving security updates, giving them flexibility to update their code as they see fit.

The patch removing the C implementation was integrated into the 7.4 merge window of the kernel, marking the completion of this significant upgrade effort.

Written by urgent.news from Lobsters's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at lwn.net →

More in Tech

More from Friday 20 November →