Rust is now ready to join C as a practical language to implement on Linux
A few weeks ago we shared here on the blog the news about the confirmation made during the Open Source Summit Europe , by Linus Torvalds, that, barring unforeseen problems, patches to support the development of the Rust driver will be included in the Linux 6.1 kernel, which is expected to be released in December.
The reason for mentioning this is that Miguel Ojeda, author of the Rust-for-Linux project , recently announced the release of the tenth proposal of components for the development of Rust device drivers for Linux kernel developers to consider.
As such this is the eleventh edition of the patches, taking into account the first released version (no version number). Linus Torvalds approved the inclusion of Rust support in the Linux 6.1 kernel, barring unforeseen problems.
It is worth mentioning that the development is funded by Google and the ISRG (Internet Security Research Group), which is the founder of the Let's Encrypt project and promotes HTTPS and the development of technologies to increase Internet security.
Some of the benefits of getting Rust support in the kernel are making it easier to write safe device drivers by reducing the chances of memory errors and encouraging new developers to get involved with the kernel.
"Rust is one of those things that I think will bring in new faces... we're getting old and grey," Linus said.
The Linux 6.0 release notes provide an update on the progress of the Rust for Linux project: there is a related working group, a preliminary driver for NVMe storage media developed with that language is available, as well as a driver for a planned server for the 9P network protocol.
Taking advantage of the mention of kernel version 6.1, Linus also announced that kernel version 6.1 will improve some of the oldest and most fundamental parts of the kernel, such as the printk() function.
Regarding this new proposal for Rust patches, just like the last version of the patches, the tenth version is reduced to the bare minimum, enough to build a simple kernel module written in Rust.
The differences with the previous version are reduced to minor corrections, replacing sizeof with ARRAY_SIZE in kallsyms.cy and adapting patches to the v6.0-rc7 kernel.
Rust support should still be considered experimental. Nevertheless,
Support is good enough that kernel developers can start working on it.
The minimal patch, reduced from 40,000 lines of code to 13,000 lines , is expected to facilitate the adoption of Rust support in the kernel. After providing minimal support, the plan is to gradually increase existing functionality by porting other changes from the Rust-for-Linux branch.
The proposed changes make it possible to use Rust as a second language for developing drivers and kernel modules. Rust support is presented as an option that is not enabled by default and does not result in Rust being included among the required build dependencies for the kernel.
Using Rust to develop drivers will allow you to create better and safer drivers with minimal effort, without problems like accessing a memory area after freeing it, dereference null pointers, and buffer overflows.
Safe memory management is provided in Rust at compile time by checking references, tracking object ownership and object lifetime (scope), and by evaluating the correctness of memory access during code execution.
Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better than the standard library, applies the concept of references and immutable variables by default, and offers strong static typing to minimize logical errors.
Finally, if you are interested in learning more about the article, you can consult the mailing lists on the topic at the following link.