Rust Programming Language To Land in Linux Kernel 6.1

Tux the penguin peeks out from behind a rusty chain
(Image credit: Miguel Á. Padriñán)

In a recent post on the Linux Kernel Mailing List, Linus Torvalds promised “a number of fairly core new things” in Linux kernel 6.1, and the first one seems to have appeared: as reported by The Register, the Rust programming language will be directly supported in the OS.

The Rust logo

(Image credit: Rust Foundation)

The news isn't exactly unexpected as patches to add Rust to Linux go back for some time, with version 9 appearing in August 2022. At the recent Open Source Summit Torvalds' keynote indicated that we should expect Rust to appear in 6.1. Right now, Rust has a group of developers working on support for the Linux Kernel and in a pull request made by Kees Cook on October 1, accepted by Torvalds, we see the first steps towards its inevitable arrival in 6.1.

Adding support for Rust adds about 12,500 lines of code to the Linux kernel, which is itself written in C, with which Rust has a certain amount of interoperability. However, GCC, the Gnu Compiler Collection, cannot compile the new language, and Clang, which can, has its own shortcomings if you want to write code for architectures other than x86 and Arm. With Rust set to receive official Linux support, and an eager community of kernel hackers, it can only be a matter of time before Rust is available to more architectures. The new kernel is expected to be available from December this year.

Some developers have already begun showing what can be done with Rust on Linux, with Western Digital’s principal engineer Andreas Hindborg showing off an NVMe SSD driver for Linux written in Rust at the 2022 Linux Plumbers Summit, which had a whole micro conference dedicated to Rust in Linux.

Rust is a general-purpose programming language influenced by C++ that was created in 2006 and hit version 1.0 in 2015. It grew out of a personal project by Mozilla employee Graydon Hoare, and was sponsored by Mozilla until 2020, when corporate restructuring caused by the Covid pandemic caused the Rust Foundation to be founded in 2021. Amazon Web Services, Huawei, Google, Microsoft and Mozilla now support the foundation, and Google supports Rust in its Android Open Source Project. The language is notable for its elegance, its zero-tolerance approach to memory safety, and the speed of its growth in popularity.

It’s also known as a high-performance language, created with the intention of marrying the flexible syntax of a high-level language with the hardware control and speed of a low-level one. Parallelism is also one of its fortes, and its strong memory safety - it notably doesn’t incorporate a garbage collector to return memory that’s no longer being referenced by a program to the system, as C# and Java do. The memory errors introduced by C programmers could be a thing of the past with Rust’s memory-safe features.

Ian Evenden
Freelance News Writer

Ian Evenden is a UK-based news writer for Tom’s Hardware US. He’ll write about anything, but stories about Raspberry Pi and DIY robots seem to find their way to him.

  • RichardtST
    As a long-time kernel developer and hacker I can tell you without any shadow of a doubt that Rust is being added to create more attack surface. Gotta have those back doors. No better place than someplace "safe". Seriously, have you looked at real Rust code? Absolutely the antithesis of the "KISS PRINCIPLE". This is bad news for linux.
    Reply
  • Kamen Rider Blade
    Why did Linus approve of integrating RUST inco the Linux Kernal?

    Can anybody tell me why?

    I'm perfectly fine with C/C++ as the main languages for the Linux Kernal

    I know RUST is a C/C++ relative, but it's like that weird cousin.

    Has RUST been tested properly for security issues?
    Reply
  • coolitic
    Kamen Rider Blade said:
    Why did Linus approve of integrating RUST inco the Linux Kernal?

    Can anybody tell me why?

    I'm perfectly fine with C/C++ as the main languages for the Linux Kernal

    I know RUST is a C/C++ relative, but it's like that weird cousin.

    Has RUST been tested properly for security issues?
    C++ is not used in the kernel, because it's unnecessarily complex and ambiguous.
    Reply
  • It C for kernel and I would like it to STAY that way
    Reply
  • bit_user
    RichardtST said:
    As a long-time kernel developer and hacker I can tell you without any shadow of a doubt that Rust is being added to create more attack surface. Gotta have those back doors. No better place than someplace "safe". Seriously, have you looked at real Rust code? Absolutely the antithesis of the "KISS PRINCIPLE". This is bad news for linux.
    Interesting take. In all the discussion and debate I've read about this on Linux-focused forums, I've not seen such claims.

    I trust this work wasn't undertaken lightly. It's been under way for several years. Right now, it's just limited to device drivers. If it turns out to be as big a liability as you claim, I'm sure it'll be addressed or removed.
    Reply
  • bit_user
    Kamen Rider Blade said:
    I'm perfectly fine with C/C++ as the main languages for the Linux Kernal
    There was never any C++. Linus is famously opposed to it. Until earlier this year, the kernel was C89 (with GNU extensions). They recently upped it to C11 (with GNU extensions). The Rust support is limited to a very small portion of it, for now.

    Kamen Rider Blade said:
    Has RUST been tested properly for security issues?
    Safety & security are its main selling points. If you're interested, I'd encourage you to read up on it.
    Reply
  • bit_user
    coolitic said:
    C++ is not used in the kernel, because it's unnecessarily complex and ambiguous.
    There were objections to it, but I think that doesn't do them justice. Suffice to say that C++ has had a long history, and it still has some reputational damage from its earlier days. I think that colored the opinions of some kernel developers who didn't personally have much experience with it.

    The other thing about C++ is that it's been fairly polarizing. Those who still use pure C have likely made a conscious choice to resist C++, making it a harder sell for getting them to adopt it. Anyway, it's a moot point (for the Linux kernel, anyway). It looks like they successfully fended off C++ and its evolutionary path will now potentially be a Rusty one.

    What I take issue with is characterizing C++ as "ambiguous", though I'd have to agree that it has a lot of complexity (or richness, as some may choose to characterize it).
    Reply
  • bit_user
    Mandark said:
    It C for kernel and I would like it to STAY that way
    Right, because the world learned nothing about writing software since the 1970's!
    ;)

    It's pretty rare, in this industry, to see people advocate for sticking with technology that's literally 50 years old. It dates back to a time when most software was written on punch cards and most "mini-computers" (which were typically refrigerator-sized) had at most a couple MB of RAM and ran at a couple MHz or less.
    Reply
  • capodistria
    Kamen Rider Blade said:
    Why did Linus approve of integrating RUST into the Linux Kernal?

    Can anybody tell me why?

    I'm perfectly fine with C/C++ as the main languages for the Linux Kernal

    I know RUST is a C/C++ relative, but it's like that weird cousin.

    Has RUST been tested properly for security issues?
    War in Ukraine (why?)
    The threat of a 3rd world war (why?)
    Nuclear war threat (why?)
    The RUST threat (why?)
    ...The answer to your question (why?) is that there is no answer.
    Reply
  • bit_user
    capodistria said:
    The RUST threat (why?)The answer to your question (why?) is that there is no answer.
    I think the reason some people feel threatened by Rust is simply resistance to change. Linux has used C for the past 30+ years, so why change it now? There's always a risk involved in any change. If you're happy with Linux as it is, then you probably don't feel you have much to gain by it. That could make the prospect of change seem scary to some.

    What the Rust advocates claim (and don't get me wrong, I'm not a Rust user, but here's their argument, as I understand it):
    Fewer bugs - Rust has memory safety features not found in C.
    Fewer security exploits - along with the memory safety, Rust also has security features as core parts of the language.
    Improved productivity - being more modern & expressive, you can do more with fewer lines of code.
    Larger talent pool - C is a rather primitive language that fewer programmers want to work in, these days.
    Somewhere in there ought to be room for performance improvements, as well. The Linux kernel has lots of algorithms and data structures, many of which weren't terribly efficient or haven't scaled well. Using a safer language that's easier to work within should (eventually) facilitate improving lots of aspects in the kernel that might've either seemed to risky or too much effort to tackle, previously.
    Reply