Rust in the Linux Kernel (2024)

Not that long ago, the idea that another major language would be supported in the Linux kernel would have been laughable. Linux was C’s poster child. Sure, there have been efforts to introduce other languages into the kernel, notably C++. They failed. Badly. As Linux’s creator Linus Torvalds once said, “C++ is a horrible language.” So, why is Torvalds now welcoming Rust into the kernel? Listen, my friend, and I’ll tell you.

Rust began as a Mozilla Foundation project. This then new scratch-built language’s purpose was to incorporate the expressive syntax and flexibility of a high-level language with the fine control and performance of a low-level language. In particular, it was meant to improve performance, parallelization, and memory safety.

It’s the combination of performance and memory safety that would catch the attention of Linux developers. While there’s no question that C enables programmers to write very fast code, there’s also no doubt that C also makes it all too easy to make memory blunders.

Decades after C arrived on the scene, memory errors with C programs appear to be the most common of all coding security mistakes. In 2019, Microsoft confessed that 70% of its Common Vulnerabilities and Exposures (CVE) security problems had been caused by developers making memory corruption mistakes in their C and C++ code.

Much as I make fun of Microsoft for its security mistakes, this isn’t the company’s problem alone. It’s everyone that uses C. As Alex Gaynor and Geoffrey Thomas at the 2019 Linux Security Summit said, two-thirds of Linux kernel vulnerabilities come from memory safety issues. It’s pretty much the same everywhere. Where-ever there’s a memory problem, chances are you’ll find C or C++.

It soon became clear to Linux kernel developers who were willing to look beyond K&R C that Rust might be the answer. True, you can try to write memory-safe programs in C with language variants like SEI CERT C or use more secure guidelines such as the C++ Core Guidelines. But, at the end of the day, there’s still a heap of C memory errors in production code.

The first step to bringing Rust and Linux together, which unfortunately came too little early, was Taesoo Kim’s 2013 Linux kernel module. Companies were watching Rust develop and coming to the conclusion that in it lay the future of system programming.

Amazon, Google, and Microsoft all came to this conclusion in the late 2010s and early 2020s. By 2018, Amazon Web Services (AWS) had used Rust for Firecracker, the open-source virtualization behind AWS Lambda and its other serverless offerings. By 2020, AWS had launched Bottlerocket, a Linux-based container operating system.

At the same time, Google was working on introducing Rust into the mobile Linux distro Android. As Google engineers said in 2021, Improving Android’s code “is a top priority for the security, stability, and quality of each Android release.” Still, “Memory safety bugs in C and C++ continue to be the most difficult to address.

Even though Google invests a “great deal of effort and resources into detecting, fixing, and mitigating this class of bugs,” … memory safety bugs continue to be a top contributor of stability issues, and consistently represent ~70% of Android’s high severity security vulnerabilities.: So, since “memory-safe languages are the most cost-effective means for preventing memory bugs, “we’re excited to announce that the Android Open Source Project (AOSP) now supports the Rust programming language for developing the OS itself.”

At the same time, Linux kernel developers, who were often Google employees, began to explore if Rust could be introduced into Linux itself. Miguel Ojeda, a Linux kernel developer, led these efforts. He created the Rust for Linux project to bring out-of-tree Rust modules to Linux in 2019.

But it really got going in 2020.

Rust for Linux

First, in April 2021, Ojeda introduced a Request for Comment (RFC) on bringing Rust into Linux on the Linux Kernel Mailing List (LKML). This was followed up in July 2020, by Nick Desaulniers, a Google software engineer at Google working on compiling the Linux Kernel with Clang and LLVM, suggesting an “in-tree Rust” session for the 2020 Linux Plumbers Conference (LPC). That resulted in the August 2020 “Barriers to in-tree Rust” talk. This, in turn, moved the idea of Rust in Linux to the front burner.

It also helped that Ojeda received financial support from the Internet Security Research Group (ISRG) and Google. The ISRG is investing in this because its chief objective is to promote memory-safe programming for critical Internet operating systems and programs such as Linux, Apache, and OpenSSL.

Then, on Sept. 20, 2021, Ojeda submitted the first pull request of the Rust for Linux project. This added the initial Rust support, including the Kbuild integration, initial built-in modules support, and the beginning of the kernel crate with Alex Gaynor’s and Geoffrey Thomas’ Safe Rust abstractions.

Sylvestre Ledru, a Debian Linux developer, ported a Rust version of Coreutils to Linux using the LLVM compiler infrastructure and its Clang C language front-end and tooling infrastructure in September 2021. Coreutils are the GNU shell core utilities. With these, Ledru booted Linux and was able to run the most popular Debian packages.

By March 2021, the idea has gotten enough steam that when I talked to Torvalds, and the Linux stable kernel maintainer Greg Kroah-Hartman, about Rust in Linux, Torvalds said, he was “in no way “pushing” for Rust, [but] I’m open to it considering the promised advantages and avoiding some safety pitfalls, but I also know that sometimes promises don’t pan out.

Kroah-Hartman was also cautiously optimistic, “It will all come down to how well the interaction between the kernel core structures and lifetime rules that are written in C can be mapped into Rust structures and lifetime rules for drivers in Rust to be able to use them properly. That’s going to take a lot of careful work by the developers wanting to hook this all up, and I wish them the best of luck.”

Others were more optimistic. Wedson Almeida Filho of Google’s Android Team said that “We feel that Rust is now ready to join C as a practical language for implementing the kernel. It can help us reduce the number of potential bugs and security vulnerabilities in privileged code while playing nicely with the core kernel and preserving its performance characteristics.”

The Rust in Linux team knew it would be a lot of work. As Ojeda said in June 2022, “The kernel is a huge project with a lot of stakeholders. Since the beginning, it was clear that adding a second ‘main’ language to the kernel would have both technical and management challenges.

They proved up to the challenge. In September 2022, Torvalds told me, “Unless something odd happens, it [Rust] will make it into 6.1.” The Linux kernel 6.1, and Rust in it, will appear by early 2023 or, with luck and good work, in late 2022.

Now, Rust, Torvalds said, will “just have the core infrastructure (i.e. no serious use case yet).” Make no mistake, though. This is a major step forward.

The first Rust work you’ll see in the Linux Next kernels will be, Ojeda said, “Rust abstractions for subsystems and write drivers and other modules” in the LKML.

Eventually, Rust will be a fully integrated second language in the Linux kernel. Don’t think, for one moment that means all 30+ million lines of the kernel are going to be rewritten in Rust. That’s not happening this side of 2050. After that, however, don’t bet against it. Rust makes any program it’s written in inherently safer than its C counterparts.

TRENDING STORIES

Steven J. Vaughan-Nichols, aka sjvn, has been writing about technology and the business of technology since CP/M-80 was the cutting-edge PC operating system, 300bps was a fast internet connection, WordStar was the state-of-the-art word processor, and we liked it. Read more from Steven J. Vaughan-Nichols
Rust in the Linux Kernel (2024)

FAQs

Is Rust being used in Linux? ›

In brief, Rust Linux is continuing to mature and is getting strong support from developers and vendors, such as Cisco, Samsung, and Canonical.

Will the Linux kernel be rewritten in Rust? ›

I'm going to say no. Not because you couldn't write a kernel in Rust… you totally can . It might even be useful to do that, Rust is a very interesting language. But Linux is a moving target, and I'm pretty sure there is no way you're going to get enough resources together on a rewrite to catch up with mainline.

What OS is written in Rust? ›

Redox is a Unix-like microkernel operating system written in the programming language Rust, which has a focus on safety, stability, and performance.

Is Redox OS usable? ›

Redox is a general-purpose operating system that can be used in many situations.

Is Rust allowed in Linux kernel? ›

Currently, the Rust support is primarily intended for kernel developers and maintainers interested in the Rust support, so that they can start working on abstractions and drivers, as well as helping the development of infrastructure and tools.

Will Rust replace C in Linux? ›

If you've cut your programming teeth on C and sleep with a copy of K&R under your pillow, don't worry. Rust will not be replacing C in the kernel anytime this decade.

Does Rust run well on Linux? ›

Do NOT buy this game if you are on GNU/Linux. GNU/Linux was a supported platform, the developers made money advertising the game with the SteamOS icon claiming it worked on gnu/linux, but they sadly found it a funny joke to later disable the support, effectively scamming all the GNU/Linux players.

How fast is Rust compared to C++? ›

It is difficult to compare the two languages in terms of speed and performance directly. Generally speaking, Rust and C++ are comparable in terms of overall speed and performance, but when we take into account unbiased benchmarking, there are many instances in which Rust will perform even better than its counterpart.

Is Rust better than Python? ›

Rust significantly outperforms Python regarding raw performance, thanks to its zero-cost abstractions and efficient code generation. Rust's emphasis on memory safety and low-level control makes it suitable for performance-critical applications where speed and efficiency are paramount.

Which OS is best for Rust? ›

I have used Linux for the past couple of decades. For me, personally, Linux is the best OS for Rust development. Everything just works. I occasionally have to do Rust development on Windows, and I struggle a lot.

Is Rust basically C++? ›

Rust is a multi-paradigm programming language that emerged as an alternative to C++ after the discovery of vulnerabilities in C++ code. Developed by Firefox, Rust was primarily created to address code and memory safety concerns. However, its capabilities extend far beyond mere protection.

Is Rust a C++ killer? ›

[Languages like Rust] do help you to write more features with fewer bugs, but they are not of much help when you need to squeeze the very last flop from the hardware you rent. I do think that Rust helps you squeeze out that last 1% of performance over C++.

Why use graphene OS? ›

GrapheneOS protects its users against zero-day vulnerabilities. To do so, the GrapheneOS implements attack surface reduction by removing unnecessary code from the OS. This includes stripping out potentially unsafe system features and keeping certain built-in apps, including core Google apps, off the device entirely.

Does anyone still use OS 2? ›

Yes! OS/2 is still being used, despite being around for nearly 30 years. A large number of enterprises rely on OS/2-based software to keep their businesses running.

Is Redox OS fast? ›

In Redox, resources can be both socket-like and file-like, making them fast enough to use for virtually everything.

Does Rust work on Linux yet? ›

The game actually works perfectly on Linux/Proton, it's just that you can't connect to EAC-enabled servers (which is nearly all of them). Game used to run native on Linux without proton. Then helk got irritated people would report bugs for the Linux build.

How much of Linux is in Rust? ›

so 0.03% of the code (ignoring comments) is written in Rust.

Does Ubuntu use Rust? ›

Rust can be installed using the Ubuntu APT (Advanced Package Tool) or the curl tool. curl is a command-line tool and library for transferring data with URLs.

Is Rust programming language now being used in the newest Linux kernel? ›

This is a major step forward. The first Rust work you'll see in the Linux Next kernels will be, Ojeda said, “Rust abstractions for subsystems and write drivers and other modules” in the LKML. Eventually, Rust will be a fully integrated second language in the Linux kernel.

Top Articles
How Sara Paid Off Over $150,000 Of Debt To Reach Financial Freedom
Teaching Your Kids Stewardship (When You’re Not Good with Money) - Teach Them Diligently
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Kelle Weber

Last Updated:

Views: 6479

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Kelle Weber

Birthday: 2000-08-05

Address: 6796 Juan Square, Markfort, MN 58988

Phone: +8215934114615

Job: Hospitality Director

Hobby: tabletop games, Foreign language learning, Leather crafting, Horseback riding, Swimming, Knapping, Handball

Introduction: My name is Kelle Weber, I am a magnificent, enchanting, fair, joyous, light, determined, joyous person who loves writing and wants to share my knowledge and understanding with you.