
It is well known that Linux is the representative of the C language. However, times have changed, and Rust is on the rise, gaining more and more support, gradually taking on the role of the system language for Linux.
At the 2020 Linux Plumbers Conference, developers seriously considered the idea of using Rust for inline code in Linux. Moreover, a lot of Rust content has already been pushed into the Linux ecosystem. For example, AWS released Bottlerocket in 2020, an open-source operating system based on Linux designed specifically for running containers, which includes a significant amount of Rust code.
Another example involves Sylvestre Ledru, who is a director at Mozilla by day and a Debian Linux developer by night. Ledru has ported a Rust version of Coreutils to Linux using the LLVM compiler infrastructure along with its Clang C language frontend and toolchain. Coreutils is known as the core utilities for GNU Shell. Based on this, he has booted Linux and run some of the most popular Debian packages. Although Ledru admits that this platform is not yet ready for production, it is now usable after a lot of hard work. One day, it may evolve to the point of replacing GNU Coreutils.
Rust’s popularity stems from its ability to help developers write safer software. Security has long troubled companies like Microsoft and Google. Previously, Microsoft researchers stated that 70% of the vulnerabilities they fix each year are related to memory safety. A Google survey also found that 70% of serious security vulnerabilities in the Chrome codebase are memory management issues.
These security problems can be addressed using Rust. AWS product manager Samartha Chandrashekar stated, “Rust helps ensure thread safety and prevents memory-related errors, such as buffer overflows that could lead to security vulnerabilities.”
It is reported that the 2019 Linux Security Summit revealed that about two-thirds of Linux kernel vulnerabilities stem from memory safety issues.
Theoretically, Rust could completely avoid these vulnerabilities by using inherently safer application programming interfaces (APIs).
Regarding the status of Rust in Linux, Linux developer Nelson Elhage summarized: The supporters of Rust in Linux are not “proposing to rewrite the Linux kernel in Rust; they are simply working to make it possible to write new code in Rust. The three potential concerns regarding Rust support include utilizing existing APIs in the kernel, architecture support, and handling the application binary interface (ABI) compatibility between Rust and C.”
Of course, can Rust replace C and dominate the Linux world? Linus, the father of Linux, and Greg Kroah-Hartman, the maintainer of the Linux stable kernel, may have the most authority to speak on this matter.
Linus has been “waiting and watching.” He said, “I am very interested in this project, but I think it is driven by people who are very passionate about Rust, and I want to see how it performs in practice.”
Linus stated, “I will never push for a Rust movement in Linux. However, given the advantages of Rust, I am open to it.”
Linus believes that the primary target for Rust seems to be drivers, as there are many different viable targets there, and these parts of the kernel are relatively small and independent. This may not be as interesting for some, but it is a very obvious target.
Another reason he considers drivers first is that “any initial attempts at drivers happen at the architecture level. Many drivers only relate to a few target architectures, so the issue of Rust code not being supported on certain architectures is not a big deal here.”
Greg Kroah-Hartman, the maintainer of the Linux stable kernel, agrees with Linus, stating, “Drivers may be the preferred area for such attempts because they are the ‘end leaves’ of the kernel source code dependency tree. They depend on core kernel functionalities but nothing depends on them.”
Linus knows that some people completely dislike the presence of Rust in user space. “People complain that the ‘Rustification’ in user space is not a good sign for the future of the kernel, but how it will unfold remains to be seen. The kernel and user space projects are different—kernels are harder to deal with in some ways (we use many very strange header files that push the boundaries of what can be called ‘C’), but in many other ways, they are easier (primarily because the kernel is fully self-contained, so the final binary does not depend on other projects).”
“It all comes down to how to map the interactions between the core structures and long-term rules of the kernel written in C to the structures and long-term rules of Rust to allow drivers written in Rust to use them correctly. Developers wanting to organize all of this will need to put in a lot of effort, and I wish them luck,” Greg Kroah-Hartman added.
Currently, it is almost certain that rewriting Linux in Rust will not happen anytime soon, but user space programs and drivers in Linux may be the first to transition to Rust.
Click at the end of the article [Read Original] to visit InfoQ’s official website for more exciting content!
Course Recommendations
Former Alibaba P9 Li Yunhua‘s “Big Company Promotion Guide” has been online for 3 months, with 13,000+ subscriptions! Now only ¥89, after 4 days it will increase to ¥199, only 4 days left! Scan the QR code below to try reading.
Li Yunhua has worked for major companies such as Huawei, UC, Alibaba, and Ant Financial. From an ordinary programmer to Alibaba P9, he passed every promotion at once. After leading teams, he guided several team members to rise from P6 to P7 and from P7 to P8. Later, he began serving as a promotion judge, responsible for the promotion review of P6, P7, and P8 levels, having reviewed dozens of candidates and worked with many judges.
These experiences have allowed him to understand the confusion and challenges employees at different positions and levels face during promotions, and he has summarized a complete promotion methodology, all detailed in his column “Big Company Promotion Guide”, delivering a complete career advancement route for you, explaining the promotion techniques from an ordinary programmer to P9, through 19 effective working and learning methods, helping you deeply understand the promotion system.