Rust Safety Standard Proposed For The Linux Kernel

Written by Michael Larabel in Linux Kernel on 17 July 2024 at 08:24 PM EDT. 79 Comments
LINUX KERNEL
While Rust is viewed as a memory safe and robust programming language, there is the "unsafe" keyword within Rust that can be used for unsafe code that grants "unsafe superpowers" for the language. As dealing with Rust at low-levels as the Linux kernel can lead to needing to use "unsafe" Rust at times, a documentation standard has been proposed for dealing with such code inside the kernel.

Benno Lossin has proposed a set of patches for introducing a Rust Safety Standard for the kernel. Lossin explains of the Rust Safety Standard effort:
"`unsafe` Rust code in the kernel is required to have safety documentation. This is to ensure the correctness of `unsafe` code and is thus very important. However, at this point in time there does not exist a standard way of writing safety documentation. This leads to confusion, as authors struggle to find the right way to convey their desired intentions. Readers similarly struggle with correctly interpreting the documentation; it's the wild west.

To alleviate this issue and to raise the quality of safety documentation, this patch series introduces a standard way of writing safety documentation.

Because creating a standard for every possible requirement is a tall task, this series starts off very small. I hope to start more discussion, in order to find the best form of safety documentation for the kernel."

This Rust Safety Standard is initially comprised of an overview, various code examples, safety requirements, justifications, and other items to be expanded upon moving forward.

Rust for Linux logo


Those interested in learning more about the Rust Safety Standard for the kernel can see these RFC patches with the tentative documentation in full.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week