Rust in the Linux Kernel: New Safety Standard Proposed for Unsafe Code
Rust is a programming language renowned for its safety and reliability. However, it includes a special keyword, “unsafe,” which allows developers to utilize unsafe code. This is sometimes necessary, particularly when working with the Linux kernel. To organize the use of such code, a new documentation standard was recently proposed.
Benno Lossin proposed an update that introduces a universal safety standard for Rust in the Linux kernel. He explains that unsafe code in the kernel must be documented to ensure its correctness. Currently, there is no unified method for writing such documentation, leading to confusion. Code authors often do not know how to properly describe their intentions, and other developers reading the code struggle to understand these descriptions.
To address this issue and improve the quality of documentation, the new standard proposes a uniform method of writing it. Creating a standard for all possible scenarios is a challenging task, so it is suggested to start small. Lossin hopes his initiative will spark further discussions and help find the best way to document code in the kernel.
The first version of the safety standard includes an overview, code examples, safety requirements, justifications, and other elements that will be expanded in the future. Those interested in learning more about the new standard can review the proposed changes and preliminary documentation.