Does Rust belong in the Linux kernel?


At least you can try to avoid it, but it’s things that “clever” language can’t stand well (ie, why do you want to test this equality twice?). I wanted Unix from that time, but neither the software or hardware was within my reach. So I got a Radio Shack Color Computer in 1984 to run OS-9. If the C community Software development articles for dummies is unwilling to appreciate and solve the fundamental problems that Aria’s piece articulates, then I don’t have much hope for the language. If rust is so great like me and you claim then let’s get our feet wet, we can write our own kernel purely in rust instead of risking to ruin our very own Linux Kernel.

If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form. I expect to see the first Rust code in the Linux kernel sometime in 2022.

  • So how are we supposed to call such a function from C code?
  • The response was that that would require “decades of development and bug fixes”, as opposed to slowly adding Rust components into Linux.
  • But first, we shall see how to integrate the Rust code inside a fully C kernel.

Unfortunately, most of the programmers I know never made it past stage 2. Exciting news, after years waiting for this I can’t full realize that it actually happened. Congrats to the Rust for Linux team, they did a superb job not just on this basic patchset but also on the many things they already built which will percolate down to mainline through the individual subsystems in the near future. As others have mentioned, it is not replacing anything. This is infrastructure for writing drivers and other new modules in Rust. While Rust programs have long since run on Linux, this adds initial infrastructure to write the kernel itself in Rust.

Security

Eventually, Rust will be a fully integrated second language in the Linux kernel. Don’t think, for one moment that means all 30+ million lines of the kernel are going to be rewritten in Rust. Rust makes any program it’s written in inherently safer than its C counterparts. It also helped that Ojeda received financial support from the Internet Security Research Group and Google.

There is still no fix for disabling bootup memory wipe and just fast power cycling. Best just keep important information in processor registers…but context switches and processor state saves on the stack. Nothing is safe if the hacker owns the hardware and has resources. Some of this depends on what you call “an operating system” – there are multiple ring levels, obviously.

One significant snag with building the kernel with Clang, though, is CPU architecture support. Only x86 and Arm are well supported this way, and other architectures are not as solid yet. Even if Rust doesn’t make it in, there will be significant improvements. Indeed, some of the oldest and most fundamental parts of the kernel, such as printk(), will be improved. Torvalds also told me in our interview that another reason he wants to see Rust in the kernel is to encourage new developers to start working on the kernel. “Rust is one of those things that I think might bring in new faces,” he said, and, “We’re getting old and gray.”

Looking ahead, Ojeda wrote, “We will keep upgrading until we do not rely on any unstable features; at which point we may want to start declaring a minimum Rust version is supported like it is done, e.g. GCC and Clang. Roadmap.sh Community created roadmaps, articles, resources and journeys for developers to help you choose your path and grow in your career. Then, on Sept. 20, 2021, Ojeda submitted the first pull request of the Rust for Linux project.

Linux Plumbers 2020

Then, we are going to pattern match the Syscall we just received. This again comes from functional programming and is the other side of the “algebraic data types” coin, which makes it so damn powerful. It looks like a switch in C-like languages, but on steroids’ steroids.

Neither is expected to replace the C version any time soon, but performance seems excellent and the authors noted that Rust offers a number of conveniences. Each step takes a huge amount of effort, PostgreSQL JSON Functions and Operators coordination and is by no means a given. 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.

rust takes toward linux kernel

Though, I have stumbled onto many Rust programmers that swears that inherently makes any program immune to memory attacks of any kind, and that just isn’t true in practice. If the hardware is an open book, then no high level code will close it. For very advanced language lawyers it might even be more readable, just because there’s only one statement to read instead of a bunch to synthesize together… Just pity the poor mortal, workaday programmer who comes along after them. This is why maintaining a great code base takes social skills as well as technical ones; you’ve got to be able to model the effects of what you’re writing on other people with different experience levels. Lastly, there’s the danger that it just doesn’t catch on. It may be that the kernel community collectively shrugs, and goes on writing code in C, and the Rust support bit-rots.

For instance, we have had discussions and feedback from maintainers of the kernel build system, documentation, testing, CIs, architecture, tooling (e.g. pahole), etc. We also had contact with several Rust teams for discussions around features the kernel needed and other topics. We talked to organizations like the Linux Foundation as well as with news organizations such as Linux Weekly News , which covered several Rust-related topics and Kangrejos. The kernel is a huge project with a lot of stakeholders. Since the beginning, it was clear that adding a second “main” language to the kernel would have both technical and management challenges. On top of that, we got contacted by several entities from the industry about their interest in the project, such as Google, Arm, Microsoft and Red Hat.

Articles from blogs I read

The community has not changed their tune one bit in the intervening 5 years, so my gut reflex is that the toolchain is still not remotely ready for mass adoption. What may be more of an issue is the added complexity of debugging problems when there is another language to consider. Until now, the kernel has enjoyed the advantage that it’s all in C and all the programmers working on it are familiar with that language. Add a second language, and now there’s C programmers, Rust programmers, and the few that are actually proficient in both. There’s yet another compiler that could possibly introduce errors, and another toolchain to manage.

Realy, it has been years since C++ proposal for the kernel has been issued with a negative feed back. The mapping from Nim to C is extremely complex. I’ve used Rust a little, though What is Ruby mostly at the “Hello, World! “Torvalds seems to have accepted the idea” is the one thing here that surprises me. Linus has always struck me as quite resistant to change.

rust takes toward linux kernel

It will be slightly more secure once you get inside a pure rust module. Does the Rust code run more reliable than the older C it is replacing. Is it faster, more secure, or easier to program. Gotta admit, I haven’t followed the discussions very closely, but I don’t understand how there can keep being interesting things to say about it. Don’t worry, nothing major will be written in it.

“I suspect that because Rust is now in the kernel, and it’s just being talked about much … more widely, that it will seem like an attractive prospect to a lot of people that are looking to develop their skills and their knowledge,” she said. Rumbul hopes people will also be inspired to participate in the language as contributors and maintainers, because those are some of the less popular roles within open source, but are extremely critical to the health of a language, she explained. Linux is, on the whole, a conservative project. It is deployed worldwide in billions of devices and its reliability is depended on by a majority of Earth’s population. Risks are carefully evaluated in Linux as such.

This was pitched for a Linux Plumbers Conference, and the mailing list response was cautiously optimistic. If Rust could be added without breaking things, and without losing the very things that makes Rust useful, then yes it would be interesting. 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.

Basic Rust Support Merged For Upcoming Linux 6.1

Developed by the same people at the same time. I think it’s totally natural for languages and toolchains to have growing pains. It doesn’t mean anything except that i hope the kernel development community rigorously tests these claims before forcing me to install a rust toolchain again.

Our code is obviously going to need to do a little bit of assembly. And while this is rather easy, due to an inline assembly system very close to the one used in C, it is also terribly unsafe, thus you have to tell the compiler in advance you are going to use it, so it can get emotionally prepared. Greg Kroah-Hartman asked how subsystem-specific Rust bindings will go upstream; will they go through the Rust tree or via the relevant subsystem maintainers? Ojeda answered that core Rust support will go through the Rust tree, but the rest should go through maintainers. Torvalds answered that it should be up to the maintainers; there is no need for global rules at this point.

Functional programming languages then, implements lambda calculus. And if a String gets passed back as a return value to the syscall, only the stack part will actually be written in userspace memory, the array of chars will remain where it was allocated by the kernel, that is in kernelspace memory. And when userspace code will try to access it, it will segfault. It is possible to avoid this problem, but it will request extra care from the developers. How useful might this be in the present context?


By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close