<!DOCTYPE html>
The Battle Over Rust in the Linux Kernel: Developers Clash with Maintainers
The Linux kernel, a cornerstone of modern computing, is undergoing a significant challenge as developers attempt to integrate Rust, a memory-safe programming language, into its architecture. However, kernel maintainers have shown strong resistance, viewing Rust as an unwelcome and risky addition due to potential complexities it introduces.
Rust for Linux: An Ambitious Project
The Rust for Linux project aims to enable Rust code to be used for writing device drivers and other kernel components. This initiative is centered on leveraging Rust’s strengths in memory safety to enhance the reliability and security of the Linux kernel.
This ambition was tested last September when Wedson Almeida Filho, a software engineer from Microsoft, stepped back from the Rust for Linux project. Filho’s departure was attributed to frustration with disagreements over project goals and the difficulties in collaborating with those holding opposing views. He referred to these issues as “nontechnical nonsense,” highlighting significant communication gaps.
“Don’t force me to deal with your shiny language of the day. Maintaining multi-language projects is a pain”
Recent Setbacks: The Rust Kernel DMA API Conflict
Disputes continue to arise over the appropriate use of Rust within the Linux kernel. A proposed abstraction aimed at allowing Rust-written device drivers to interact with the kernel’s Direct Memory Access (DMA) API—a core component written primarily in C—recently faced organized resistance.
Specifically, a patch was submitted that would enable Rust drivers to utilize the DMA API’s dma_alloc_coherent() function to allocate and map large memory regions required for hardware communication. The patch was intended to reside in the rust/kernel directory, preserving separation from the C-centric kernel/dma codebase.
Kernel maintainer Christoph Hellwig, however, rejected this proposal outright. In a message to the Linux kernel mailing list, Hellwig firmly stated, “No Rust code in kernel/dma, please.” Hellwig’s opposition was rooted in his belief that incorporating Rust into this specific area would complicate maintenance and reduce the readability of critical code.
Seeking Compromise: An Open Discussion
Miguel Ojeda from the Rust for Linux project reached out to Hellwig, requesting him to suggest an alternative approach if the patch were unacceptable. Hellwig’s response was blunt: “Keep the wrappers in your code instead of making life painful for others.” He emphasized the importance of keeping interfaces in readable C code to ensure that it remains “greppable and maintainable.”
Hellwig further clarified his stance, stating, “Don’t force me to deal with your shiny language of the day. Maintaining multi-language projects is a pain I have no interest in dealing with.” According to Hellwig, developers using alternative languages, including Rust, should interface with the kernel through C bindings managed by themselves.
Danilo Krummrich, a Red Hat software engineer involved in the Rust for Linux project, pushed back against Hellwig’s position. Krummrich explained that developing Rust bindings in a centralized manner within the `rust/kernel` tree would streamline the process and reduce duplication. This approach would allow Rust developers to maintain abstraction layers without affecting the core C codebase.
Code of Conduct and Broader Implications
Hector Martin, the project lead of Ashai Linux, criticized Hellwig’s comments as a potential violation of the project’s Code of Conduct. Martin argued that Hellwig’s remarks were not conducive to fostering a collaborative environment and questioned whether any disciplinary measures would be taken.
Martin advised the Rust for Linux developers to submit their patch for review and approval by Linus Torvalds, the kernel’s primary maintainer. Martin contended that the Rust community should merge the series once it is reviewed and ready to avoid prolonged delays and conflicts. “Everything else is beating around the bush,” he emphasized.
The Case for Rust in the Linux Kernel
The introduction of Rust into the Linux kernel was made official on October 3, 2022. This decision was catalyzed by Mark Russinovich, Microsoft’s Azure CTO, who advocated for Rust’s use in modern projects, emphasizing its superior memory safety and reliability. Russinovich’s stance was aligned with growing worldwide interest in Rust, particularly from government security organizations aiming to mitigate memory safety issues.
Despite these advancements, C and C++ developers have expressed skepticism about integrating Rust. Several initiatives have emerged to enhance the safety of C and C++ languages, including projects like TrapC, FilC, Mini-C, Safe C++, and DARPA’s TRACTOR. These efforts aim to reduce memory-related vulnerabilities and bridge the gap between legacy languages and modern safety standards.
There are people who just don’t like the notion of Rust, and having Rust encroach on their area
Linus Torvalds: A Balanced Perspective
Linus Torvalds, the prominent figurehead of Linux kernel development, has acknowledged the friction between C and Rust developers. Speaking at the Linux Foundation’s Open Source Summit in Vienna, Austria, Torvalds highlighted the inevitability of resistance to new languages encroaching on established territories.
“Clearly, there are people who just don’t like the notion of Rust, and having Rust encroach on their area,” Torvalds observed. He also noted that discussions about Rust’s potential failure are premature, emphasizing that the process of integrating new technologies is inherently experimental.
Conclusion: The Future of Rust in Linux
The ongoing debate over the inclusion of Rust in the Linux kernel highlights the complexities and challenges of maintaining such a vital and historically C-centric project. While Rust enthusiasts argue for the benefits of memory safety and enhanced reliability, traditionalists emphasize the importance of stability and maintainability.
As developments continue, the outcome of this conflict may determine the future direction of Linux kernel development. Whether Rust proves to be a valuable addition or remains an experimental niche depends on the broader community’s willingness to embrace change and adapt.
