The Rust Programming Language Is Now One Step Closer To Entering The Mainline Linux Kernel

From LinuxReviews
Jump to navigationJump to search
Tux-000e.svg

The Linux kernel community has been discussing the possibility of using the Rust programming language to write new kernel device drivers since last summer. Initial Rust support has now landed in the Linux-Next tree. This does not guarantee that Rust will be supported or even allowed in the mainline kernel, but it does mean that there is now a fair chance that Rust will eventually be required to successfully compile a Linux kernel.

written by 권유리 (Kwon Yu-ri)  2021-03-20 - last edited 2021-03-20. © CC BY

Make-menuconfig-5.11.6.jpg
make menuconfig on Linux kernel 5.11.6.

Googles Nick Desaulniers started pushing for "in tree" Rust support in the Linux mainline kernel with a message titled "Linux kernel in-tree Rust support" in July 2020. The discussion of the wisdom of allowing Rust to be used for Linux driver development has been on-going since then. The discussions and the behind-the-scenes work has now yielded tangible results.

Kernel developer Miguel Ojeda announced that Rust support for the Linux kernel is now in linux-next!" in a message to the "Rust-for-linux" mailing list on March 18th, 2021. He noted that:

"Thanks to Stephen Rothwell, we are now in linux-next!

This does not mean we will make it into mainline, of course, but it is a nice step to make things as smooth as possible."

We are now in linux-next!
posted by Miguel Ojeda on Rust-for-linux on March 18th, 2021

The actual commit to linux-next, hailed by kernel developer and security researcher Alex Gaynor as "an exciting milestone", contains 3451 lines of code in 29 new files in a rust/ folder. It has a rather short commit message:

"This is a draft for linux-next. This message is intentionally bare-bones for the moment. It is not representative of the final contents and will be rebased."

Building a Linux-next kernel will Rust support requires the Rust compiler (rustc) and a fairly recent nightly snapshot of the Rust toolchain. That limits the currently supported platforms to x86-64 and arm64.

The Linux-Next Rust merge did not include any actual kernel drivers or other code using Rust to provide useful functionality. It does make it possible to write Linux kernel drivers in Rust. Doing so would be a gamble that Linus Torvalds approves the code for inclusion into the mainline Linux kernel. Torvalds has indicated that he is open to the idea as long as it is disabled automatically if Rust isn't present at compile-time:

"No, please make it a "is rust available" automatic config option. The exact same way we already do the compiler versions and check for various availability of compiler flags at config time."

A lot of code goes from Linux-Next to the mainline kernel almost as a matter of routine, and it would be natural to assume that the code would make it into the next major kernel version when Linux 5.12 is released and the merge window opens if it was a smaller change. Rust support is a rather big change. The amount of code isn't huge, but the implications are. There are some good reasons why Linus Torvalds may want to leave the Rust support in Linux-Next for a release-cycle or three before he merges the changes into the mainline Linux kernel. He could, for example, question why the commit contains 103 instances of the word "unsafe".

It is impossible to know what will happen during the Linux 5.13 merge window when it opens, we can only wait and see if Rust makes it into the next mainline kernel or not.

4.43
(7 votes)

avatar

Anonymous user #1

23 days ago
Score -3++
HOW ABOUT NO
avatar

Anonymous user #2

23 days ago
Score -4++
FUCK YOU RUST YOU DOOMED US ALL!
avatar

Chaekyung

22 days ago
Score 1++
Please mind your language, this is a family-friendly website.
avatar

Anonymous user #2

23 days ago
Score -2++
LINUX WAS ALREADY GOOD AS IS AND RUST RUINED IT WITH ITS SHIT
avatar

Anonymous user #3

23 days ago
Score 3++

The new GCC-rs can't come any sooner. Apart from the inherent lack of supported platforms of LLVM, this is indeed a very good update. Rust's enforcement of strict private ownership model is substantially going to reduce the risk of common memory-safety vulnerabilities created by buffer-overflows, dangling pointers, double free, data-races so on and so forth.

I also believe it'll be easier to contribute to Linux if Rust gets accepted in mainline because it reduces risks that inherently come with C as mentioned above. Exciting times :)

~bruce3434
avatar

Anonymous user #4

23 days ago
Score 0++
FOURTH ALL-CAPS ANGRY COMMENT
avatar

Anonymous user #5

23 days ago
Score 0++
Wow y'all are fucking mad.
avatar

Anonymous user #6

23 days ago
Score -1++
EVERYTHING MAKES ME ANGRY!!
avatar

Anonymous user #7

23 days ago
Score 0++

oh haha x) I never get anger only other peoples :P

emotions?? hehe dummy dude just stop caring!
avatar

Anonymous user #8

23 days ago
Score -1++
If this gets merged, and it will, it will be the beginning of the end of Linux. Rust justice warriors are a cancer
avatar

Anonymous user #9

22 days ago
Score 0++
How exactly will rust be the end of linux? I don't get it. Please elaborate.
avatar

Anonymous user #25

22 days ago
Score 0++
Rust justice warriors care more about their agenda to infect everything with rust rather than actual improvements. Normal people who done understand that they have an agenda are not sufficiently prepared to reject their propaganda. Soon it will transition from rust being “optional” to rust being required for certain “tier 1” platforms. Then certain subsystems will be rewritten, because “why not?” Then old maintainers who are not sufficiently “inclusive” to rust script kiddies will be ousted. Then script kiddies pretending to be kernel hackers will take over maintainer roles because all the good kernel hackers hated their irrational groupthink. This will be considered good because rust is “inclusive” but Linux will be shit. Everyone competent will move to openbsd, until rust justice warriors infect that community as well. Rust justice warriors will not cease until all public programming communities allow incompetent rust justice warriors to commit whatever trash they want without being told it’s trash.
avatar

Anonymous user #10

22 days ago
Score 1++
ARRRR.... NEW THINGS MAKE ME SOOO ANRGY WITHOUT A REASON.
avatar

Anonymous user #19

22 days ago
Score 0++

Change can be scary. Change brings uncertainty, and every man fears the unknown.

"Today Americans would be outraged if U.N. troops entered Los Angeles to restore order; tomorrow they will be grateful. This is especially true if they were told there was an outside threat from beyond, whether real or promulgated, that threatened our very existence. It is then that all peoples of the world will plead with world leaders to deliver them from this evil. The one thing every man fears is the unknown. When presented with this scenario, individual rights will be willingly relinquished for the guarantee of their well being granted to them by their world government." Henry Kissinger, Speaking at a Bilderberg Corp board meeting in Evian, France, on May 21, 1992.
avatar

Anonymous user #11

22 days ago
Score 1++
There are so many nonsense comments here that I'd like to continue this trend with this one. :-)
avatar

Anonymous user #12

22 days ago
Score 1++
rust is love rust is life
avatar

Anonymous user #13

22 days ago
Score 2++
I don't understand the hate. Rust drivers will be more resilient to memory issues, and typically permits the programmer to work on features rather than fixing bugs, without a reduction in performance. The *only* issue is that the compiler has to do a little more work to produce the executable, but again, with fewer bugs, I suppose there are fewer compiles required. This is a generalisation of course.
avatar

Anonymous user #25

22 days ago
Score 0++
Rust drivers in Linux will be security theatre since the underlying interfaces cannot and never will be “safe” and the rust justice warriors pushing this crap know it. Alex Gaynor certainly does, but they don’t care. Rust justice warriors care more about infecting everything with rust even if no practical benefit results.
avatar

Anonymous user #32

19 days ago
Score 0++
Nothing will ever be 100% safe so don't bother trying to improve safety ever. Better just post your ssn here since no system will 100% be able to protect it.
avatar

Anonymous user #14

22 days ago
Score 1++
Hate comes from ignorance
avatar

Anonymous user #15

22 days ago
Score 1++
I AM GOING TO MAKE MULTILLE ANONYMOUS COMMENTS MAKING STRAW MAN ARGUMENTS RATHER THAN ACTUALLY STATING MY GRIEVANCES
avatar

Anonymous user #16

22 days ago
Score -1++
LOUD CRAB NOISES
avatar

Anonymous user #17

22 days ago
Score 0++
What is linux?
avatar

Anonymous user #18

22 days ago
Score 1++
This is exciting! I love Rust.
avatar

Anonymous user #19

22 days ago
Score 1++
Does that mean linux will officially drop support for i686? Rust does not support it, it is limited to arm64 and x64-64, so if it worms its way inside the kernel that's a given.
avatar

Anonymous user #24

22 days ago
Score 1++
No. Gccrs is a front-end. It converts code toan intermediate representation that gcc can then turn into anything it supports.
avatar

Anonymous user #20

22 days ago
Score 2++
Rust makes me angry. When its on my car but I love that the kernel is getting rusty.
avatar

Anonymous user #21

22 days ago
Score 0++
RUST IS GOING TO INVADE THE PLANET AND KILL ALL HUMANS.
avatar

Anonymous user #22

22 days ago
Score 0++
damn, some of you guys really dislike evolution
avatar

Anonymous user #25

22 days ago
Score 0++
Calling rust “evolution” is a Orwellian manipulation technique. Your rust justice warrior tactics will not work
avatar

Anonymous user #32

19 days ago
Score 0++
This week on "I don't know what Orwellian means"
avatar

Anonymous user #23

22 days ago
Score 0++
rust and javascript is literally the new plague in tech
avatar

Anonymous user #26

22 days ago
Score 1++

There is nothing in this article to support the headline. There is definitely some heavy "cart before the horse" excitement going on here.

Nothing against Rust itself as a language, but the Rust community really needs to calm themselves down with "remake everything in Rust" crusade, it is seriously giving the language a bad name and turning people off from trying it, when it itself is a very powerful tool.
avatar

Anonymous user #27

22 days ago
Score 2++
It makes me sad how so many ignorant people with no technical background are ranting now without a reason. Rust make safe abstractions easier to write then c. U Safe c interfaces are no problem when they are implemented the right way, that's actually a great argument for rust. So what exactly is the problem ? Script kiddies ??? Just because rust makes it easier to write good code than c doesn't mean that the programmers behind the code are dumb, actually another good reason for rust, it could make the entrance in Linux easier for more developers... You guys are literally making a fool out of ourselves
avatar

Anonymous user #28

22 days ago
Score 0++

RUST FRICKING SUCKS WHY DID YOU HAVE TO DO THIS TO US LINUX USERS

RUST WILL FALL ONE DAY PEOPLE!! ONE DAY!!!!!!
avatar

Anonymous user #29

21 days ago
Score 0++

I have a problem with a lot of this.

First off rust is dependant on cargo. I would like not to be requiring on a third party repository to build linux

second the rust syntax is terrible and for version 2 i think they should replace it with something readable.

third is with the rust community in itself. It is a very toxic community filled with evangelists.

fouth is the support rust has for other architectures. compared to C which has excellent support(largely due to gcc) for other architectures rust is largely based on the centralized compiler. If gnu decided to add it along with other compilers to the gcc i would have less of an issue with it.

Other than that I have an issue with the idea of safe languages vs C. The gcc compiler has a ton of warning flags that make the compiler just as annoying to you as the rust compiler.
avatar

Anonymous user #30

20 days ago
Score 0++

> Rust depends on cargo

What's wrong with cargo again?

> Syntax is terrible

It's not terrible, you are not used to namespace, generics and lifetime annotations.

> community is toxic

The only toxicity I see is from tech-illiterate C fizzbuzz specialists who are continuously spamming this very thread, to be quite honest. And 99% of these spammers have never committed a single line to Linux nor they ever will. I know this because they never have written critical programs in C to value the added memory safety or modern abstractions.

> gcc has warning flags

GCC 11 and other static analysis tools are mind-numbingly primitive than Rust's enforcement of private resource ownership model.
avatar

Anonymous user #31

20 days ago
Score 0++
You can trivially build rust programs without cargo. The compiler, rustc is a separate entity. Alternately, Linux org can maintain its own cargo server with select audited libraries.
Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.