Linus Torvalds weighs in on Rust language in the Linux kernel (2024)

safer frameworks —

"Memory managed languages? In my kernel?" It's more likely than you think.

Jim Salter -

Linus Torvalds weighs in on Rust language in the Linux kernel (1)

This week, ZDNet's Steven J. Vaughan-Nichols asked Linus Torvalds and Greg Kroah-Hartman about the possibility of new Linux kernel code being written in Rust—a high performance but memory-safe languagesponsored by the Mozilla project.

C versus Rust

As of now, the Linux kernel is written in the C programming language—essentially, the same language used to write kernels for Unix and Unix-like operating systems since the 1970s. The great thing about C is that it's not assembly language—it's considerably easier to read and write, and it's generally much closer to directly portable between hardware architectures. However, C still opens you up to nearly the entire range of catastrophic errors possible in assembly.

In particular, as a nonmemory-managed language, C opens the programmer up to memory leaks and buffer overflows. When you're done with a variable you've created, you must explicitly destroy it—otherwise, old orphaned variables accumulate until the system crashes. Similarly, you must allocate memory to store data in—and if your attempt to put too much data into too-small an area of RAM, you'll end up overwriting locations you shouldn't.

High-level languages—such as PHP, Python, or Java—aim to be both easier to read and write and safer to write code in. A large part of the additional safety they offer comes from implicit memory management—the language itself will refuse to allow you to stuff 16K of data into a 2K buffer, thereby avoiding buffer overflows. Similarly, high-level languages automatically reclaim "orphaned" RAM via garbage collection—if a function creates a variable which can only be read by that function, then the function terminates, the language will reclaim the variable once it's no longer accessible.

Rust, like Google's Go, is one of a new generation of languages which aims to hit somewhere in between—it provides the raw speed, flexibility, and most of the direct mapping to hardware functionality that C would while offering a memory-safe environment.

Linux Plumbers 2020

At the Linux Plumbers conference in 2020, kernel developers began seriously discussing the idea of using Rust language inside the kernel. To be clear, the idea isn't an entire, ground-up rewrite of the kernel in Rust—merely the addition of new code, written in Rust, which interfaces cleanly with existing kernel infrastructure.

Torvalds didn't seem horrified at the idea—in fact, he requested that Rust compiler availability be enabled by default in the kernel-build environment. This didn't mean that Rust-code submissions would be accepted into the kernel willy-nilly. Enabling automatic checks for Rust-compiler presence simply meant that it should be as easy as possible to get any potential submissions built (and automatically tested) properly like any other kernel code would.

Fast forward to 2021

A significant amount of work has been done on Rust in the kernel since the 2020 Linux Plumber's Conference, including on a Rust-language port of GNU Coreutils. The port's author, Sylvestre Ledru—a Mozilla director and Debian developer—describes it as being in working condition, though not yet production ready. Eventually, the Rust port might replace the original GNU Coreutils in some environments—offering built-in thread safety and immunity to memory management errors such as buffer overflows.

Torvalds says he's in the "wait and see" camp about all this:

I'm interested in the project, but I think it's driven by people who are very excited about Rust, and I want to see how it actually then ends up working in practice.

Torvalds goes on to describe device drivers as obvious low-hanging fruit for potential new work to be done in Rust. He says that because there are tons of them, and they're relatively small and independent of other code.

Kernel maintainer Greg Kroah-Hartman agrees:

... drivers are probably the first place for an attempt like this as they are the "end leafs" of the tree of dependencies in the kernel source. They depend on core kernel functionality, but nothing depends on them.

Kroah-Hartman goes on to describe the difficulties which must be overcome for successful production integration of Rust code into a primarily C-language kernel:

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... 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.

An important first step

Although we don't expect to see a full implementation of the Linux kernel in Rust anytime soon, this early work on integrating Rust code into the kernel's C infrastructure is likely to be very important.

Both Microsoft and the Linux community agree that two-thirds or more of security vulnerabilities stem from memory-safety issues. As software complexity continues to increase, making it safer to write in the first place will become more and more important.

Linus Torvalds weighs in on Rust language in the Linux kernel (2024)

FAQs

Linus Torvalds weighs in on Rust language in the Linux kernel? ›

Linux Plumbers 2020

Does Linus use Rust? ›

Hohndel and Torvalds also talked about the use of the Rust language in the Linux kernel. Torvalds said, "It's been growing, but we don't have any part of the kernel that really depends on Rust yet.

How much does the Linux kernel weigh? ›

I remember it was 60-70 MB when I started using Linux. Today I updated my system. I saw the kernel was 162 MB. I think it is only within less than 10 years that the Linux kernel has got an extra 100 MB.

Is the Linux kernel written in Rust? ›

Rust for Linux is a series of patches to the Linux kernel that adds Rust as a second programming language to C for writing kernel components.

Is the Linux kernel being rewritten in Rust? ›

"There are real technical reasons like memory safety and why Rust is good to get in the kernel." Mind you, no one is going to be rewriting the entire 30 or so million lines of the Linux kernel into Rust.

Does Rust run faster on Linux? ›

The difference is quite small, but the C version is faster (it takes about 10 minutes less on Linux). But, as far as I know, Rust's performance should be equal or even better than C's.

Why is Linux moving to Rust? ›

Rust's entry into the Linux kernel isn't arbitrary; it's a strategic move driven by several advantages. One of the primary benefits is the significantly improved memory safety that Rust offers.

How much Rust is in the Linux kernel? ›

1 Answer. so 0.03% of the code (ignoring comments) is written in Rust. For now that's mostly support code; 6.8 will likely have one phy driver written in Rust.

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.

Is Microsoft rewriting Windows in Rust? ›

Microsoft is rewriting core Windows libraries in the Rust programming language, and the more memory-safe code is already reaching developers. David "dwizzle" Weston, director of OS security for Windows, announced the arrival of Rust in the operating system's kernel at BlueHat IL 2023 in Tel Aviv, Israel, last month.

Is Rust better than go? ›

If you love building products quickly, choose Go. It's ideal for those who want to develop swiftly and see immediate results. If, on the other hand, you're passionate about constructing products you can swear by, can afford to invest more time, or simply want to appear cool, choose Rust.

Is Rust like C? ›

Rust is a multiparadigm, compiled programming language that developers can view as a modern version of C and C++. It is a statically and strongly typed functional language. Rust uses syntax similar to C++ and provides safety-first principles to ensure programmers write stable and extendable, asynchronous code.

Is Rust installed on Linux? ›

Installing rustup on Linux or macOS

The command downloads a script and starts the installation of the rustup tool, which installs the latest stable version of Rust. You might be prompted for your password. If the install is successful, the following line will appear: Rust is installed now.

What programming languages does Linus Torvalds use? ›

At Open Source Summit, Linus Torvalds described his early career, how he built Linux and his continuing love for the C programming language.

What is the best Linux editor for Rust? ›

Visual Studio Code (VS Code)

Visual Studio Code is an open source and free-for-use project created by Microsoft and available for macOS, Windows, and Linux. It supports a lot of major languages, including Rust. Currently, VS Code is one of the best code editors around and the most-used editor for Rust development.

Top Articles
What are cryptocurrency network fees? | Learn about crypto and DeFi | Get Started with Bitcoin.com
Is rental income passive or active? Why it matters
Pollen Count Los Altos
Best Pizza Novato
855-392-7812
Craigslist Mpls Mn Apartments
Ingles Weekly Ad Lilburn Ga
How Far Is Chattanooga From Here
Jasmine
Sitcoms Online Message Board
Busty Bruce Lee
Most McDonald's by Country 2024
Dr Adj Redist Cadv Prin Amex Charge
DBZ Dokkan Battle Full-Power Tier List [All Cards Ranked]
The Exorcist: Believer (2023) Showtimes
Free Online Games on CrazyGames | Play Now!
Pay Boot Barn Credit Card
Veracross Login Bishop Lynch
Phoebus uses last-second touchdown to stun Salem for Class 4 football title
Homeaccess.stopandshop
yuba-sutter apartments / housing for rent - craigslist
Village
Walgreens Bunce Rd
Gs Dental Associates
The Boogeyman (Film, 2023) - MovieMeter.nl
Free T33N Leaks
Cosas Aesthetic Para Decorar Tu Cuarto Para Imprimir
Yayo - RimWorld Wiki
HP PARTSURFER - spare part search portal
Log in to your MyChart account
2487872771
Google Jobs Denver
What Time Is First Light Tomorrow Morning
The Land Book 9 Release Date 2023
Indiefoxx Deepfake
The Bold And The Beautiful Recaps Soap Central
Ticketmaster Lion King Chicago
Sams La Habra Gas Price
Paperless Employee/Kiewit Pay Statements
Gateway Bible Passage Lookup
All Characters in Omega Strikers
Giovanna Ewbank Nua
'The Nun II' Ending Explained: Does the Immortal Valak Die This Time?
Menu Forest Lake – The Grillium Restaurant
2294141287
The Pretty Kitty Tanglewood
Doelpuntenteller Robert Mühren eindigt op 38: "Afsluiten in stijl toch?"
Google Flights Missoula
Sml Wikia
Buildapc Deals
Craigslist Charlestown Indiana
Latest Posts
Article information

Author: Laurine Ryan

Last Updated:

Views: 6440

Rating: 4.7 / 5 (77 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Laurine Ryan

Birthday: 1994-12-23

Address: Suite 751 871 Lissette Throughway, West Kittie, NH 41603

Phone: +2366831109631

Job: Sales Producer

Hobby: Creative writing, Motor sports, Do it yourself, Skateboarding, Coffee roasting, Calligraphy, Stand-up comedy

Introduction: My name is Laurine Ryan, I am a adorable, fair, graceful, spotless, gorgeous, homely, cooperative person who loves writing and wants to share my knowledge and understanding with you.