Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Programming Linux

Torvalds: Rust Kernel Code Isn't Forced In Over Maintainers' Objections (kernel.org) 60

Linus Torvalds responded Thursday to kernel developer Christoph Hellwig, who had claimed Torvalds merged Rust code into the kernel even over his objections as the original C code's maintainer. Highlights from Torvalds' response: The fact is, the pull request you objected to DID NOT TOUCH THE DMA LAYER AT ALL. It was literally just another user of it, in a completely separate subdirectory, that didn't change the code you maintain in _any_ way, shape, or form... 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. You are saying that you disagree with Rust — which is fine, nobody has ever required you to write or read Rust code. But then you take that stance to mean that the Rust code cannot even use or interface to code you maintain...

You don't have to like Rust. You don't have to care about it. That's been made clear pretty much from the very beginning, that nobody is forced to suddenly have to learn a new language, and that people who want to work purely on the C side can very much continue to do so. So to get back to the very core of your statement:

"The document claims no subsystem is forced to take Rust"

that is very much true. You are not forced to take any Rust code, or care about any Rust code in the DMA code. You can ignore it...

You can't have it both ways. You can't say "I want to have nothing to do with Rust", and then in the very next sentence say "And that means that the Rust code that I will ignore cannot use the C interfaces I maintain".... So when you change the C interfaces, the Rust people will have to deal with the fallout, and will have to fix the Rust bindings. That's kind of the promise here: there's that "wall of protection" around C developers that don't want to deal with Rust issues in the promise that they don't *have* to deal with Rust.

But that "wall of protection" basically goes both ways. If you don't want to deal with the Rust code, you get no *say* on the Rust code. Put another way: the "nobody is forced to deal with Rust" does not imply "everybody is allowed to veto any Rust code".

Torvalds also made sure to add some kind remarks, including "I respect you technically, and I like working with you."

Torvalds: Rust Kernel Code Isn't Forced In Over Maintainers' Objections

Comments Filter:
  • by Viol8 ( 599362 ) on Saturday February 22, 2025 @11:01AM (#65187015) Homepage

    of the kernel code. Not because of the language itself but because it seems to me that for right or wrong its causing a whole load of grief with people working on the code. If certain people want to force Rust into the kernel for whatever reason perhaps it would be best if they just forked it like Google did and work on their own version then it can sink or swim based on its own merits.

    • I wonder how much benefit it gives. I imagine it's not negligible considering Torvald's support for it, but wouldn't code be riddled with "unsafe" blocks in Rust to get the desired kernel-level control?

      • by guardiangod ( 880192 ) on Saturday February 22, 2025 @11:42AM (#65187115)

        Take a look at the Linux CVE list- https://lists.openwall.net/lin... [openwall.net] . Over 80% of the bugs are from drivers, with over 300 suspected security bugs in January 2025 alone. If Rust even quash 30% of them (fair assessment since memory management in C is hard) then Rust in Linux would be considered a success.

        • by gweihir ( 88907 )

          On the other hand, there is this: https://cve.mitre.org/cgi-bin/... [mitre.org]

          • by ebunga ( 95613 )

            Let me preface this by sayinng I do not like rust. I find the language ugly, and most of its cult members highly annoying at best.

            Only one bug in that list you posted was related to memory management, and the worst case scenario is memory exhaustion, and not root@pwnedbox:~#

            Other bugs are logic errors that simply result in undesired behavior, rather than root@pwnedbox:~#

      • by AuMatar ( 183847 )

        Not riddled. There would be certain sections that are unsafe that deal with direct device/memory access. Those could be separated out, and the algorithmic parts of the kernel (which is the vast majority) can use that as an API when needed. Far less of the kernel deals directly with device control than you'd think.

      • by Samare ( 2779329 ) on Saturday February 22, 2025 @12:43PM (#65187259)

        Quoted from Greg Kroah-Hartman [wikipedia.org]:

        The majority of bugs (quantity, not quality/severity) we have are due to the stupid little corner cases in C that are totally gone in Rust.
        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.)

        https://lkml.org/lkml/2025/2/1... [lkml.org]

      • but wouldn't code be riddled with "unsafe" blocks in Rust to get the desired kernel-level control?

        And why you think code riddled with "unsafe" blocks is just going to be accepted? If I was a maintainer of any code, my first question would be why is the submitter posting a patch that has lots of "unsafe" blocks?

        • by HiThere ( 15173 )

          I think that if you're interfacing with hardware the "unsafe" blocks are often going to be necessary. Which, of course, eliminates much of the reason to use rust in the first place.

          OTOH, I'm NOT an expert in this field. This is based of encounters with attempts to "make code safe" multiple decades ago.

          • I think that if you're interfacing with hardware the "unsafe" blocks are often going to be necessary. Which, of course, eliminates much of the reason to use rust in the first place.

            But why would it be "necessary"? Is unsafe C blocks just written all the time?

            OTOH, I'm NOT an expert in this field. This is based of encounters with attempts to "make code safe" multiple decades ago.

            The whole point of Rust is safer code. If it isn't safer, why develop unsafe Rust code? They could stick to existing C code in that case.

    • by UnknowingFool ( 672806 ) on Saturday February 22, 2025 @01:11PM (#65187331)

      Not because of the language itself but because it seems to me that for right or wrong its causing a whole load of grief with people working on the code.

      By your argument, Linux should never add on anything new because it would cause a lot of grief to someone.

      . If certain people want to force Rust into the kernel for whatever reason perhaps it would be best if they just forked it like Google did and work on their own version then it can sink or swim based on its own merits.

      Except you like Hellwig are framing the problem in the same way. Linus decided Rust in the kernel should be supported. Zero part of the core kernel has Rust. As the founder of Linux, Linus has decided the kernel should support it for optional development. If you don't want Rust support in Linux, why don't you create a fork?

    • No, Linux should follow evolution of programming languages. I never wrote a line of code in Rust, but I can see the appeal. Being stricter, it forces programmer to apply rigor and formalism in writing the code and that code will be more secure in the long term, both later when someone tries to modify it or just by bitrot, i.e. with the risk of other changes in the codebase creating vulnerabilities in this code that were previously not possible.
      There will always be resistance and changes can be postponed, bu

    • by DRJlaw ( 946416 )

      Perhaps Rust should have been kept out of the kernel code. Not because of the language itself but because it seems to me that for right or wrong its causing a whole load of grief with people working on the code. If certain people want to force Rust into the kernel for whatever reason perhaps it would be best if they just forked it like Google did and work on their own version then it can sink or swim based on its own merits.

      No. Fuck you for suggesting the exact same thing as Hellwig except for on a grander

      • I dont fucking care sonny, was just a post. Now run along to mummy, she's done your dinner.

        • by DRJlaw ( 946416 )

          Awww, did I hurt your little feewings? Or did Linus reject your println!("Hello world!"); contribution because you screwed up your syntax?

          • LOL :) No hurt feelings, sorry, but you did give me a good laugh. You're just another unintentionally amusing troll probably with size issues who pretends to be the big shoot from the hip tough guy online. Now go play with your fwuffy wuffy teddy bear cupcake :)

            • by DRJlaw ( 946416 )

              LOL :) No hurt feelings,

              The fact that you keep responding strongly suggests otherwise, and very much shows that you care.

              Your initial post was not just "a post." If it was, you wouldn't be so triggered by these replies.

  • by Mr. Dollar Ton ( 5495648 ) on Saturday February 22, 2025 @11:02AM (#65187019)

    Haven't seen or heard of anyone so successful with a kindergarten this large since FDR.

    • What we NEED is some major extensions (not macro hacks) to C to allow functionality of Rust instead of failing to address big problems that led to the creation and popularity of Rust in the 1st place. That makes it into an optional security feature instead of yet another programming language with a few new ideas + a bunch of preferential decorations.

      • What we NEED is some major extensions (not macro hacks) to C to allow functionality of Rust instead of failing to address big problems that led to the creation and popularity of Rust in the 1st place.

        Okay, why don't you start doing that since you seem to have the answer? How about the fact that no one seemingly has added this major functionality to C speaks to the difficulty. Remember C is not some brand new programming language that no one knows anything about. C is over 50 years old and there even a standards for C. ANSI C is on version C23 (October 2024). If you can convince someone of this need and get it passed by ANSI, go right ahead. No one is stopping you.

        However in 2012, Graydon Hoare and Mozi

      • What we NEED is some major extensions (not macro hacks) to C to allow functionality of Rust

        It's been done [github.com]. And done [github.com].

        And you know what it looks like every time? Basically as if somebody tried to rewrite rust, only they did it half-assed because their borrow checker implementation doesn't work particularly well, or the code ends up being clunky and non-ergonomic.

        That last one is actually a rarely spoken of and very underrated feature of rust, but it's something the rust development team has spent a ton of effort towards without ever really advertising it: Ergonomic code. Especially when it comes to

    • by ls671 ( 1122017 )

      +5 you just made my day

    • by KGIII ( 973947 )

      That and Linus has changed over the years.

      I'm going to say he matured and became more diplomatic.

  • by Shazatoga ( 614011 ) on Saturday February 22, 2025 @11:30AM (#65187081)
    It is also about bringing in new coders. Younger coders want to program in Rust, not C. Linux needs the new blood from the community, or it will end up under the control of IBM, Google, Facebook and the like.
    • .... or it will end up under the control of IBM, Google, Facebook and the like.

      Linux is, to a large extent, under the direction of those who contribute, and the majority of the significant contributions are from those major companies (and their ilk) or the organizations those major companies fund, and they fund those people to work on things those companies customers want.

      One of the things their customers want is fewer bugs and security issues. Rust is not magic, and can't fix all mistakes, but it can eliminate a large class of errors that even the existing experienced developers

    • I'm Running into this a work. We have YEARS of Java code and it's a Mess. Look I did Java for 20+ years. It still works, but our group is doing micro services in Kubernetes. Go (or Rust) works better since it's compiled, we don't have to create pods configured with a JDK + other Java stack things... Gradle etc .. For Micro services its easier, faster. We have other old guys that just won't let it go. On top of that the younger developers we get are hard to keep, cause they don't want to do Java.

      • by HiThere ( 15173 )

        Go could easily be a better choice, if only it could be documented with Doxygen.
        I really want to like go, but the documentation system is ... lets be kind and say unpleasant.

  • I am just a bystander, but I am concerned that Rust will bifurcate the knowledge required to program the kernel. Fewer people will have what it takes to see the big picture. I have no great love the C, but it was designed from the get-go to make Unix, which is pretty close to what Linux is. https://en.wikipedia.org/wiki/... [wikipedia.org]

    Yes, any mistake made programming a kernel will either have terrible consequences if the bug is large, or cause hidden problems if the bug is small--but this is the nature of writing an
    • by StormReaver ( 59959 ) on Saturday February 22, 2025 @12:06PM (#65187157)

      ...but I am concerned that Rust will bifurcate the knowledge required to program the kernel.

      I don't think it matters nearly as much as you might think. No one can maintain the entire kernel, as it's too big for one person to hold in memory. There are already subsystems using other languages (the kernel config, for example, at least used to be written in a non-C language). There are maintainers and maintainers for the maintainers. As Linus stated, there are walls between the Rust portions and the C portions of the kernel, and never shall the two be forced to meet.

      Someone maintaining the Rust code will maintain the Rust code, and someone maintaining the C code will maintain the C code, and I see absolutely nothing wrong with this. Whether a Rust maintainer will ever work on the C code will depend on whether the Rust programmer also wants to maintain C. The C code will remain C code. Whether a C programmer wants to work on the Rust code will depend on whether the C programmer also wants to maintain Rust. The Rust code will remain Rust.

      Christoph is afraid of change (change can be hard, so it's understandable), and is making a mountain out of a speck of dust.

      • @StormReaver: I believe that yours is an appropriate perspective. I don't do kernel stuff. I currently use Rust for an application server and CLTs and would never use C again if I could avoid it, but I cannot imagine trying to force Rust on anyone. C is relatively easy conceptually and syntactically, but has some risks. Rust is quite challenging in all areas even after quite a bit of use. I still battle with the compiler and little "quirks" constantly, and various aspects could be much more mature. Rust has
    • by _merlin ( 160982 ) on Saturday February 22, 2025 @12:21PM (#65187187) Homepage Journal

      The trouble is, computers are far bigger and more complex now than when C and the UNIX kernel emerged. There was nothing anywhere near the complexity of, for argument's sake, a modern GPU driver, and there was no computer with enough memory to compiling something as complex as a modern GPU driver. C isn't good at scaling up to this level of complexity, and developers start demanding more expressive languages to help them manage the complexity.

      Now I know you're thinking, "He's going to say we should be using C++ in the kernel," but I'm not. Yes, I'm a C++ developer, but I can recognise that C++ isn't a great fit for the kernel. Encapsulation, templates and automatic unwind would be great, but other parts of C++, not so much. You'd need to use some subset of C++ without exceptions, and that would mean you couldn't use the throwing new operator or anything that depends on it for propagating errors, which means a lot of the standard library is out of the question, and you need to write your constructors in an "un-C++" way. It would make "kernel C++" effectively a different language for a developer to learn anyway. The NeXTStep kernel (and by extension the XNU kernel, at least in the first few versions of Mac OS X) used a subset of C++ like this for drivers. It felt weird to use.

      Is Rust a great fit for the kernel? I don't know, I don't have a huge amount of experience with it. There are some things that seem worrying. For example the way it reorders structure members means you can't organise a large structure to keep members that are accessed as a group together. It relies on shared pointers an awful lot, which means it does a lot of interlocked memory operations, and that has a significant performance cost. I don't like the lack of a formal standard or multiple implementations - that was a very real issue for Perl 5 where the documentation literally said that if the implementation and documentation disagreed, the implementation was correct.

      So anyway, for better or for worse, the two language choices for kernel work are C and Rust, so developers who want a more expressive language than C are flocking to Rust. They aren't necessarily choosing Rust because it's ideal for what they're doing, they're choosing it because it's that or C, and C sucks for a lot of the things they're doing. Rust may not be ideal, but is more expressive than C and helps manage complexity.

      • There are some things that seem worrying. For example the way it reorders structure members means you can't organise a large structure to keep members that are accessed as a group together.

        Annotate your struct with #![repr(c)]. One line, that's it. Really. But don't do it if you don't need to -- this disables a compiler optimization in the name of compatibility. If your struct isn't crossing a language boundary, there's no need for this.

        It relies on shared pointers an awful lot, which means it does a lot of interlocked memory operations, and that has a significant performance cost.

        Not sure what you mean by this. If it's pointer aliasing, which does carry a performance cost, safe rust doesn't even permit this. Unlike C++, there's no need precede everything with "const" and "strict" everywhere -- you get that implicitly everywhere in rust

    • by raynet ( 51803 )

      I don't think there is much danger of that happening. Most likely almost all Rust code will be limited to drivers, and there will always be C drivers too. So anyone wanting to implement a new driver can pick C or Rust based on their preferences. And for fixing bugs, most of them are simple enough that any competent programmer can fix them in both languages.

    • I am just a bystander, but I am concerned that Rust will bifurcate the knowledge required to program the kernel.

      Knowing a computer language does not give you knowledge of how to program the kernel. Understanding the details of kernel programming does that. Just like the fact that someone speaking German instead of English doesn't magically make them more logical or a better university lecturer. There's a difference between knowing the language and using it. The knowledge required to program the kernel is unchanged, you just need to speak the language, and programming languages are not hard to learn, the fundamentals

    • by UnknowingFool ( 672806 ) on Saturday February 22, 2025 @02:07PM (#65187463)

      As a bystander, I have questions: Is it a fling with Rust--or will it replace C for programming the Linux Kernel? If it is just a fling, perhaps it would be best to keep it out and let the experiment run in a parallel fork. If it's not a fling--then is your Rust coder base large enough to replace all the C programmers? Because--do you really think that most C programmers are going to jump ship to Rust?

      Rust code is not part of the main Linux kernel. It is optional for drivers to use it so support must be in Linux. As of now, Rust is being tested to see how well it works. If it accomplishes the goals that proponents have championed like reducing critical bugs, someday it might replace C. But that day is not today. What we see is a lot of resistance to any idea of Rust. In this case Linus pointed out Hellwig's objection to Rust meant he was actively preventing others from using Rust. Imagine if another maintainer said something along the lines of "RISC-V will never work, and I will do everything I can in Linux to prevent it from working even in code I don't maintain."

    • Fewer people will have what it takes to see the big picture.

      A valid concern, but not really applicable because the big picture here is the interfaces, not the code itself. You only need a one-weekend level of understanding of the other language to talk with people about the interfaces and issues they might have.

      And there is no need for Rust to replace anything. New stuff that is written in Rust will require a Rust maintainer, but new written in C already required somebody submitting it for inclusion to agree to also maintain it. C stuff will continue to be maintaine

  • Point them at the Linux kernel developers list. Christ, what a bunch of hens.

Unix soit qui mal y pense [Unix to him who evil thinks?]

Working...