News: 1740098326

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Linux royalty backs adoption of Rust for kernel code, says its rise is inevitable

(2025/02/21)


Updated Some Linux kernel maintainers remain unconvinced that adding Rust code to the open source project is a good idea, but its VIPs are coming out in support of the language's integration.

In an ongoing thread on the Linux kernel mailing list, Greg Kroah-Hartman, a senior project developer, for one urged fellow contributors to embrace those interested in contributing Rust code to improve the kernel.

Adding another language shouldn't be a problem, we've handled much worse things in the past

"Yes, mixed language codebases are rough, and hard to maintain, but we are kernel developers, dammit. We've been maintaining and strengthening Linux for longer than anyone ever thought was going to be possible," he [1]wrote on Wednesday.

"We've turned our development model into a well-oiled engineering marvel, creating something that no one else has ever been able to accomplish.

"Adding another language really shouldn't be a problem. We've handled much worse things in the past, and we shouldn't give up now on wanting to ensure that our project succeeds for the next 20-plus years. We've got to keep pushing forward when confronted with new good ideas, and embrace the people offering to join us in actually doing the work to help make sure that we all succeed together."

[2]

His posts are the latest in a spat which [3]began last month when a proposed patch to allow Rust-written device drivers to call the primarily C-based kernel's core [4]DMA API was challenged by kernel maintainer Christoph Hellwig.

[5]

[6]

Hellwig likened maintaining a multi-language codebase [7]to cancer as he emphasized his disinterest in having to take on the burden of helping maintain Rust device driver code. The ensuing argument prompted Hector Martin, then project lead of Asahi Linux, to demand that Linus Torvalds decide whether the patch would be pulled into the kernel or not.

Torvalds eventually responded by defending the Linux kernel development process and [8]scolding Martin for grandstanding on social media about the issue. Martin later quit as a Linux maintainer and [9]resigned from the Asahi Linux project.

Policy pugilism

Miguel Ojeda, who contributes to the Rust for Linux project and to Linux kernel maintenance, [10]attempted to reassure the kernel development community by publishing a " [11]Rust kernel policy ."

Hellwig, who earlier this week [12]chimed in to reiterate his concerns about mixing Rust and C code in a single codebase, criticized Ojeda's Rust for Linux policy document on grounds it appeared on the web rather than in the kernel code tree.

[13]

He also expressed concern about the role of Rust in the kernel.

"I'd like to understand what the goal of this Rust 'experiment' is: If we want to fix existing issues with memory safety we need to do that for existing code and find ways to retrofit it. A lot of work went into that recently and we need much more," he wrote.

[14]Type-safe C-killer Delphi hits 30, but a replacement has risen

[15]Time to make C the COBOL of this century

[16]Even Linus Torvalds can have trouble with autocycle … autocracy… AUTOCOMPLETE!

[17]'Maybe the problem is you' ... Linus Torvalds wades into Linux kernel Rust driver drama

In case you came in late, Rust was added to the Linux kernel in 2022 because it allows better memory safety than C.

Technical experts have for years pointed out that the majority of serious bugs and vulnerabilities in large codebases arise from memory safety errors, which could or should be avoided by using memory-safe languages and tooling. Boffins and governments thus argue that developers should use [18]memory-safe programming languages – eg, Rust, Go, C#, Java, Swift, Python, and JavaScript – whenever possible and as appropriate.

This is a prima facie sensible idea given the ubiquity of Linux.

The majority of bugs are due to the stupid little corner cases in C that are totally gone in Rust

Veteran C and C++ programmers, however, are understandably worried their skills could become less relevant. Many have therefore sought ways to achieve or approach memory safety without jumping on the Rust bandwagon.

Kroah-Hartman, [19]in response to Boqun Feng, a kernel developer with Microsoft, addressed the issue of Rust and memory safety directly.

[20]

"The majority of bugs (quantity, not quality and severity) we have are due to the stupid little corner cases in C that are totally gone in Rust," he wrote.

"Things like simple overwrites of memory (not that Rust can catch all of these by far), error path cleanups, forgetting to check error values, and use-after-free mistakes. That's why I'm wanting to see Rust get into the kernel, these types of issues just go away, allowing developers and maintainers more time to focus on the real bugs that happen (i.e. logic issues, race conditions, etc.)."

Kroah-Hartman goes on to say that he supports making C code more robust and that work won't stop, regardless.

"But for new code and drivers, writing them in Rust where these types of bugs just can't happen (or happen much much less) is a win for all of us, why wouldn't we do this?" he wrote.

"C++ isn't going to give us any of that any decade soon, and the C++ language committee issues seem to be pointing out that everyone better be abandoning that language as soon as possible if they wish to have any codebase that can be maintained for any length of time."

That comes with the usual caveats – as Kroah-Hartman acknowledged, Rust isn't a silver bullet that will magically solve all problems. But it will help, he insists.

Linus absolutely is going to merge Rust code over a maintainer's objection

It seems Kroah-Hartman is not alone in holding that view. Kees Cook, a kernel security engineer at Google and a long-time kernel contributor, for instance [21]said : "I don't see any reason to focus on replacing existing code – doing so would actually carry a lot of risk. But writing new stuff in Rust is very effective."

Among the issues raised about Ojeda's Rust kernel policy post, Hellwig corrected Ojeda's assertion that some kernel subsystem maintainers might decide they simply don't want Rust code and that that's to be expected and accepted.

"Linus in private said that he absolutely is going to merge Rust code over a maintainer's objection," Hellwig said. "So as of now, as a Linux developer or maintainer you must deal with Rust if you want to or not."

Count Torvalds in, too. ®

Updated to add

Torvalds has [22]politely responded to Hellwig's objections to Rust bindings being added to the kernel for the DMA API, correctly pointing out the proposed Rust code isn't even in the core C-based component that Hellwig maintains – the bindings act as a separate interface between the unchanged C API and Rust drivers.

Read the full email, but here are some excerpts...

The fact is, the pull request you objected to DID NOT TOUCH THE DMA LAYER AT ALL. Honestly, what you have been doing is basically saying "as a DMA maintainer I control what the DMA code is used for". And that is not how any of this works.

What's next? Saying that particular drivers can't do DMA, because you don't like that device, and as a DMA maintainer you control who can use the DMA code?

That's literally exactly what you are trying to do with the Rust code.

So let me be very clear: if you as a maintainer feel that you control who or what can use your code, YOU ARE WRONG.

You are not forced to take any Rust code, or care about any Rust code in the DMA code. You can ignore it. But "ignore the Rust side" automatically also means that you don't have any *say* on the Rust side.

"I respect you technically, and I like working with you," the kernel chief added.

Get our [23]Tech Resources



[1] https://lore.kernel.org/rust-for-linux/2025021954-flaccid-pucker-f7d9@gregkh/

[2] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=2&c=2Z7gIe1pb01qdnHHrD3OK_wAAAdg&t=ct%3Dns%26unitnum%3D2%26raptor%3Dcondor%26pos%3Dtop%26test%3D0

[3] https://www.theregister.com/2025/02/05/mixing_rust_and_c_linux/

[4] https://docs.kernel.org/core-api/dma-api-howto.html

[5] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z7gIe1pb01qdnHHrD3OK_wAAAdg&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[6] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33Z7gIe1pb01qdnHHrD3OK_wAAAdg&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[7] https://lore.kernel.org/lkml/20250128092334.GA28548@lst.de/

[8] https://www.theregister.com/2025/02/07/linus_torvalds_rust_driver/

[9] https://www.theregister.com/2025/02/13/ashai_linux_head_quits/

[10] https://www.theregister.com/2025/02/11/rust_for_linux_project_support/

[11] https://rust-for-linux.com/rust-kernel-policy

[12] https://lore.kernel.org/rust-for-linux/Z7SwcnUzjZYfuJ4-@infradead.org/

[13] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=4&c=44Z7gIe1pb01qdnHHrD3OK_wAAAdg&t=ct%3Dns%26unitnum%3D4%26raptor%3Dfalcon%26pos%3Dmid%26test%3D0

[14] https://www.theregister.com/2025/02/19/delphi_turns_30/

[15] https://www.theregister.com/2025/02/18/c_opinion/

[16] https://www.theregister.com/2025/02/18/linus_torvalds_autocomplete_mistake/

[17] https://www.theregister.com/2025/02/07/linus_torvalds_rust_driver/

[18] https://www.memorysafety.org/docs/memory-safety/

[19] https://lore.kernel.org/rust-for-linux/2025021954-flaccid-pucker-f7d9@gregkh/

[20] https://pubads.g.doubleclick.net/gampad/jump?co=1&iu=/6978/reg_software/oses&sz=300x50%7C300x100%7C300x250%7C300x251%7C300x252%7C300x600%7C300x601&tile=3&c=33Z7gIe1pb01qdnHHrD3OK_wAAAdg&t=ct%3Dns%26unitnum%3D3%26raptor%3Deagle%26pos%3Dmid%26test%3D0

[21] https://lore.kernel.org/rust-for-linux/202502191026.8B6FD47A1@keescook/

[22] https://lore.kernel.org/rust-for-linux/CAHk-=wgLbz1Bm8QhmJ4dJGSmTuV5w_R0Gwvg5kHrYr4Ko9dUHQ@mail.gmail.com/

[23] https://whitepapers.theregister.com/



beast666

The enshitification of Linux commences.

Mostly Irrelevant

I predict you've never written a line of Rust and are likely not even a programmer. Rust is well designed, modern language, and the memory safety is a great feature.

klh

I wonder if COBOL programmers behaved like C ones are today.

Anonymous Coward

Definitely.

Something to Ponder

An_Old_Dog

An operating system written in COBOL.

Is COBOL memory-safe?

Veteran C and C++ programmers, however, are understandably worried...

Anonymous Coward

"Veteran C and C++ programmers, however, are understandably worried their skills could become less relevant."

I've been writing code over 53 years. I demand that no one learn anything new, and we go back to abacuses because, damn it, they are the oldest computing devices. And unless the rods break, they are memory-safe! Old school should be the only school. If they were good enough for the Sumerian's in ~2500BC, they are good enough for you today!

Re: Veteran C and C++ programmers, however, are understandably worried...

jake

I use an abacus near daily. It's the only calculator I've found that will last in the feed barn. Sliderules gum-up something fierce with all the various plant sugars involved ... but the ol' abacus is self-cleaning.

As a side note, I am not even remotely worried about my skills becoming less relevant. The concept is a joke as far as I'm concerned. Good coders can find work in any language, and they know it .

claimed

I’ve said it before and I’ll say it again:

Don’t like Rust? Cool

Don’t see the value in Rust? Hubris

“I’ve already got an immune system, antibiotics just mean swallowing giant pills and are not needed if your cells just kill bacteria like they’re supposed to”

jake

I don't think anybody intelligent has said "I see no value in Rust".

What people are saying is "Rust will bring more problems to the existing kernel than it will solve".

There is no doubt in my mind ...

jake

... that eventually, C will no longer be used as the language for the Linux kernel. It is inevitable. Things change over time.

However, I have many doubts that Rust is the language that will be the one to take the place of C. If Rust is truly better than C for kernel work, Rust will take over as kernel coders spread the news. That's how it works. The best, most efficient code wins. That's how it has always worked in the 60ish years I've been coding in the free software world (DECUS, early '60s).

Rust seems to not be taken up by the vast majority of kernel coders, ergo ...

I rather suspect that it won't be the next language du jour that takes over from C, either. Nor the next.

What it'll take is a major paradigm shift[0] in programming that all (or at least vast majority of) kernel coders can get behind. My gut feeling is that the seeds of this new way of looking at programming haven't even been planted as yet. And no, before anyone says it, so-called "artificial intelligence" will not be a part of the answer.

I'll bet that the bulk of the Linux kernel will probably still be coded in C long after I am gone, and probably well past my great-grand kids programming careers (assuming).

[0] I hate that phrase just as much as you do ... but I think it actually fits there.

Re: There is no doubt in my mind ...

GNU SedGawk

I personally think the tooling is getting better slowly and those improvements start to feed back into later C language revisions.

A lot of the sharp edges about C are C89 or earlier - who says C29 has to maintain a rigid refusal to incorporate quality of life improvements, which today are implicit patterns.

"The best, most efficient code wins."

An_Old_Dog

True. Unless human politics and/or money and/or sex are involved.

Welcome to the real world of vested interests and irrational humans.

Things Which Ought be Considered About ANY Add'l Language for Kernel Work

An_Old_Dog

* Subroutine/function calling convention: does the proposed language play nicely with the other programming language(s) used in the kernel?

* Does the proposed additional language require an interpreter or LLVM? Those are significantly-large attack surfaces.

* Is the proposed language free-as-in-freedom, truly-open-source, and free-as-in-beer? I have not forgotten the BitKeeper debacle.

* Is the proposed language reasonably-easy to learn and understand by people lacking eidetic memories? ( APL fails this test.)

* Is the proposed language and its associated libraries stable over the long term? ( C passes this test. Python does not.)

"Adding another language really shouldn't be a problem."

Notas Badoff

Please pardon my derailing your thread, but I'm bothered by something not mentioned in any of these "It's war!" articles.

Um, what other languages are used inside Linux. Aren't there just C and C++ ? And a smattering of assembler? And C++ is still being digested?

Unless there were some large multiple of two languages _already_ being used in Linux, a statement like the above title just gives me instant heartburn.

Yeah, right, boss, anything you say! (calcium pills gonna be a rare earth 'round here!)

Re: Things Which Ought be Considered About ANY Add'l Language for Kernel Work

swm

Is there a standard for the RUST language?

Is there more than one compiler for the language?

Does the gnu compiler collection support RUST?

Will future versions of RUST invalidate old code?

Let me get the popcorn

DoctorNine

I feel approximately the same way about squabbles between Linux maintainers as I used to in my youth about Saturday morning TV wrestling. Very entertaining as a spectator sport, but not to be taken too seriously. First, regardless of the skill level of the various fellows dressing tights, the whole thing is referreed by a certain individual who weilds a mean rapier, and rather enjoys exhibiting his skill with it. And second, the outcome of the whole mess is going to be reasonably benign, because everyone has to keep working together for the next show. Those who get too emotional and rage quit, need to remind themselves about point one above. In my personal opinion of course.

Dying is easy. Comedy is difficult.
-- Actor Edmond Gween, on his deathbed.