Rust Developers Move Ahead With Preparing To Upstream More Code Into The Linux Kernel
![LINUX KERNEL](/assets/categories/linuxkernel.webp)
Miguel Ojeda who has been leading the Rust for Linux effort sent out a set of 28 patches on Thursday that provide more Rust core additions to the kernel. Ojeda explained in the patch series this latest big patch series:
This patch series is the first batch of changes to upstream the rest of the Rust support.
In this instance, all the facilities introduced are part of the "Rust core". They do not interact with the C side in new major ways (no new C types used; only `strlen`, `memchr`, additional error codes and some more `printk` format strings).
After this series, `str.rs` and `print.rs` are in sync with downstream and all remaining proc macros have been added. `error.rs` is fairly complete too, though a few more `pub(crate)` features will come later (to avoid leaving dead code in-between series).
Note that a few temporary `#[allow(dead_code)]` attributes are used in order to have a bit more freedom organizing the patches while keeping all of them buildable without warnings/errors, but at the end of the series there is none remaining (of the temporary ones).
Virtually all the code has been in linux-next for months and was part of the Rust patch series before the trimming down (i.e. up to v8).
Each patch has been built-tested on a Rust-enabled `defconfig` with `CLIPPY=1` on the `all`, `rustfmtcheck`, `rustdoc` and `rusttest` targets.
Given that this code has been in linux-next for a while and already saw some review as part of the original Rust for Linux patch series, it's quite possible we could see this work ready in time for the Linux 6.2 merge window next month. We'll see. In any case the Rust for Linux train continues rolling on.
Once all this Rust infrastructure is in place, we'll see how long it takes before more prominent, real-world drivers begin transitioning over to Rust code either for new hardware support or rewriting existing C driver code in Rust. One of the first major users of Rust in the Linux kernel is expected to be the DRM driver for the Apple M1/M2 graphics.
Separately, yesterday the US National Security Agency published guidance on protecting against memory safety issues. The NSA report suggests using the Rust programming language or other memory-safe languages like Swift, Java, Go, Ruby, and C#.
57 Comments