Rubriky
Software Development

Linus Torvalds says Rust is coming to the Linux kernel

Show Your Support, Go Premium Phoronix Premium allows ad-free access to the site, multi-page articles on a single page, and other features while supporting this site’s continued operations. It seems like adding Rust has doubled the kernel build time. Not only is the Linux kernel train bearing down on the 6.1 station, but countless other devs are waking up to the memory-safe language. To me personally the most astonishing fact about Jung’s thesis is that it manages to repeatedly cite and reference the computer scientist Tony Hoare without quoting the inventor of the Rust language, Graydon Hoare, a single time.

Runs directly on the metal, with no garbage collection or virtual machines in the way? But all the things that make C great for kernel programming also make C dangerous for kernel programming. There is gathering momentum around the idea of adding Rust to the Linux kernel. Why exactly is that a big deal, and what does this mean for the rest of us?

I prefer to encourage people to write new software to replace established software, rather than rewriting the established software. Some projects, such asRedox, are doing just that with Rust. However, operating systems are in a difficult spot in this respect. Writing an operating system is difficult work with a huge scope — few projects can hope to challenge Linux on driver support, for example. The major players have been entrenched for decades, and any project seeking to displace them will have decades of hard work ahead of them and will require a considerable amount of luck to succeed.

This added the initial Rust support, including the Kbuild integration, initial built-in modules support, and the beginning of the kernel crate with Alex Gaynor’s and Geoffrey Thomas’ Safe Rust abstractions. First, in April 2021, Ojeda introduced a Request for Comment on bringing Rust into Linux on the Linux Kernel Mailing List . This was followed up in July 2020, by Nick Desaulniers, a Google software engineer at Google working on compiling the Linux Kernel with Clang and LLVM, suggesting an “in-tree Rust” session for the 2020 Linux Plumbers Conference .

I do not insist on the configuration line, you already understood it. So how are we supposed to call such a function from C code? By telling Rust’s compiler not to mess with the name and let it the way we intended. Finally, the function asm_syscall() is called on the raw pointer, and the actions being done there are totally unsafe.

Instead, allow me to simply illuminate these issues as risk factors. The Rust programming language has already become Linux’s de facto second Linux language. It has several advantages over C, Linux’s root language. The biggest of these is it’s much better at memory security than C is.

linusw

But using Cheat Engine as an example of how there’s no memory protection is a false analogy. But relegating memory security to the OS is ripe for abuse, and that were what the cheat engine example were intended to point out, or rather how little actual security there is in practice. Paging is the basic process of splitting memory up into pages, period. Those individual pages can have access rights and be mapped to physical memory .

  • You can write your own panic handler, but unless you’ve got some profoundly good reason to do so (i.e. you’re writing software whose outcome means life vs death) then why?
  • That is, it serves as a static library and a header file all at once.
  • This address might be comprised between 0 and 0xffffffffffffffff, while syscall numbers only amount up to a bit more than 512.
  • A big project like the kernel has a great deal of shared tooling around making its languages work, so adding another one is quite an undertaking.
  • The profession of programming needs to let these “only bad programmers do this…” memes die if we’re going to leave “dark arts” and move into engineering practice.

This then new scratch-built language’s purpose was to incorporate the expressive syntax and flexibility of a high-level language with the fine control and performance of a low-level language. In particular, it was meant to improve performance, parallelization, and memory safety. Instead, Bottomley suggested that, rather than bringing in Rust, it might be better to just move more Rust-like features into C.

But both of these adds even more complexities and usually access latency. Yes, a lot of architectures do have methods of securing memory from unintentional writing and execution. And some architectures How to Become a Data Scientist Step by Step Guide even have read protection too. But depending on the architecture, the security features on offer can vary drastically in how they work, if and when one interacts with them, and what they protect.

Support Phoronix The mission at Phoronix since 2004 has centered around enriching the Linux hardware experience. In addition to supporting our site through advertisements, you can help by subscribing to Phoronix Premium. You can also contribute to Phoronix through a PayPal tip or tip via Stripe. For those wanting to reminisce, back in 2008 was the big milestone of open-source rendered triangles with the ATI RV770 GPU.

How to SECURELY delete files in Linux?

I can tell you from my one exposure to rust that i found forwards-incompatible code. Surely, the original author did something wrong. In fact, i hope and pray that he did, because the idiom he was using was really braindead…it called out for a generic type but he didn’t use it even though rust supposedly has it.

rust takes toward linux kernel

Ts’o added that Rust’s locking abstractions should be made to work with the lockdep locking checker from the beginning. Chris Mason interjected that, if lockdep is needed for Rust code, that will be another sign that the language has succeeded and it will be time to „do a victory dance“. Yeah, the main use of strncpy was for copying UNIX directory entries, which were zero-padded but not zero-terminated.

PikaOS is a next-gen Linux distribution aimed specifically toward gamers

Thus, userspace code compiled with one version of the source might not be compatible with a kernel compiled with another version of the code. The fact that the stdlib and the kernel are compiled at the same time and from the exact same source attenuates the problem, as long as the softwares are dynamically linked to the stdlib. The only thing missing for you to fully understand how the new style syscalls work is the assembly part. But first, we shall see how to integrate the Rust code inside a fully C kernel.

rust takes toward linux kernel

The less programming done by someone who has no idea what they are talking about, the better off we all are. He’s one of the big names in the discussions about how Rust should evolve and has written a lot of great, deep, highly-detailed blog Remote AWS Cloud Engineer Jobs posts on memory models and undefined behaviour and the like. I’m no fan of “must rewrite everything in rust because we could find and fix issues we don’t even know we have.” Rust rewrite is no better than big money spent on lotto tickets.

One way around might be to never change the order of the variants, and only adding new ones at the end of the enum, so the number of the preexisting ones should remain the same across versions. To understand well, this is a reduced version of what happens when an old style C syscall is being called. And finally, we compile the rlib anew, but this time only the userspace parts, which makes a nice “stdlib” for us to use later. It will be found in the root directory of the source code. A rlib is very interesting output, because it contains the compiled code, but also all the exported types, functions, and so on.

We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing. So, as Ojeda told ZDNet this summer, „The project is not finished, but we are ready to get mainlined if high-level maintainers accept the current changes and prefer that we work inside YAML tutorial: Get started in 5 minutes the kernel. Most of the work is still ahead of us.“ Led by Josh Triplett, Rust language lead, and Nick Desaulniers, a Google engineer, they proposed using the system-level Rust language inside the kernel. Because it’s much safer than C, especially at handling memory errors. At the virtual 2020 Linux Plumbers Conference, where the top Linux kernel developers hash out Linux’s future, the idea of introducing Rust as the kernel’s second language was introduced.

The Meta Language ML

Sylvestre Ledru, a Debian Linux developer, ported a Rust version of Coreutils to Linux using the LLVM compiler infrastructure and its Clang C language front-end and tooling infrastructure in September 2021. With these, Ledru booted Linux and was able to run the most popular Debian packages. Not that long ago, the idea that another major language would be supported in the Linux kernel would have been laughable. Sure, there have been efforts to introduce other languages into the kernel, notably C++. As Linux’s creator Linus Torvalds once said, “C++ is a horrible language.” So, why is Torvalds now welcoming Rust into the kernel? Improvements on the Rust compiler, standard library and tooling, such as making rustc_parse_format compile on stable or the addition of the no_global_oom_handling and no_fp_fmt_parse gates.

He says that because there are tons of them, and they’re relatively small and independent of other code. But, on the whole, my opinion is that the benefits of Rust in Linux are negligible and the costs are not. That said, it’s going to happen, and the impact to me is likely to be, at worst, a nuisance. Though I would have chosen differently, I wish them the best of luck and hope to see them succeed.

Why it’s all happening for the Rust programming language, how it made it into the Linux kernel, and where it will go from here. In July 2020, Nick Desaulniers sent an email to the Linux Kernel Mailing List about putting together an “in-tree Rust” session for the 2020 Linux Plumbers Conference . That email resulted in a few of us presenting the „Barriers to in-tree Rust“ talk in August 2020, which triggered quite a few discussions and feedback in the LPC hackrooms.

Napsat komentář

Vaše e-mailová adresa nebude zveřejněna. Vyžadované informace jsou označeny *

16 − sixteen =

error: Content is protected !!