The patch to add Rust support to the Linux kernel is ready

On July 4, a revised set of patches was submitted to the Linux kernel mailing list. The patch provided support for using Rust as an auxiliary programming language in the Linux kernel. With Rust, the security of the Linux kernel and memory can be improved.

The whole set of patches contains 17 sub-items. It not only provides preliminary Rust support for the Linux kernel but also provides a driver example with a total of more than 33,000 lines of new code.

Facebook Rust Foundation

Miguel Ojeda has been leading the work of “Rust for Linux”. Previously, we also reported that Google-funded the project to improve the security of the Linux kernel so that this programming language can be used in the kernel. Although the kernel merger of Linux 5.14 is still in progress, this set of patches is not currently marked as “Pull Request”, so it is expected that this set of patches will not officially land on Linux until the next merge cycle.

The enabling of Rust for Linux has now reached more than 33,000 lines of code. One of the reasons why so much code is included is that a subset of Rust’s “alloc” standard library is currently included in the data structure, and some content has been added to it. This allows developers to customize according to their needs. At the same time, provide the required time to upstream to evaluate this change. The ultimate goal is to put everything the kernel needs in the upstream “alloc” and remove it from the kernel tree

Another change of these new patches is that in the previous version if you want to compile the Linux kernel, you need to use the nightly version of the Rust compiler, and now the kernel can use the beta and stable versions of the Rust compiler. However, because the support for the kernel does require some of the latest features of the Rust compiler, the Beta version and the stable version will fail to compile under certain circumstances.

In addition to supporting AArch64, PowerPC, and x86_64, ARM 32-bit and RISC-V are now also supported by this Rust for Linux. For more details, you can find these latest Rust for Linux kernel patches in the kernel mailing list.