Miguel Ojeda, the author of the Rust-for-Linux project, proposed for consideration by the Linux kernel developers the release of v5 components for device driver development in the Rust language. This is the sixth edition of the patches, taking into account the first version, which was published without a version number. Rust support is considered experimental but is already included in the linux-next branch and is sufficiently developed to begin work on creating abstraction layers over kernel subsystems, as well as for writing drivers and modules. Development is funded by Google and the Internet Security Research Group (ISRG), which is the founding organization of the Let’s Encrypt project and promotes HTTPS and the development of technologies to enhance internet security.
As a reminder, the proposed changes allow Rust to be used as a secondary language for developing drivers and kernel modules. Rust support is presented as an option, not enabled by default, and does not lead to Rust being included among the mandatory build dependencies for the kernel. Using Rust for driver development will enable creating secure and higher-quality drivers with minimal effort, free from issues such as dereferencing freed memory, null pointer dereferencing, and buffer overflows.
Safe memory handling in Rust is ensured at compile time through reference checking, ownership tracking of objects, and considerations of object lifetimes (scope), as well as runtime checks for correctness in memory access. Rust also provides protections against integer overflows, requires variables to be initialized before use, manages errors more effectively in the standard library, employs immutability by default for references and variables, and offers strong static typing to minimize logical errors.
The new version of the patches continues to address the comments raised during the discussions of the first, second, third, fourth, and fifth editions of the patches. In the new version:
- The toolchain has been updated to Rust 1.59.0. The new version of Rust has also synchronized the alloc library variant, eliminating potential generation of 'panic' states when errors occur, such as memory shortages. The use of assembly insertions ('feature(global_asm)') has been stabilized.
- Support has been added for creating host programs in Rust used during kernel compilation.
- Instead of supplying pre-built files with specifications for target platforms, dynamic generation based on the kernel configuration is ensured.
- A kernel parameter HAVE_RUST has been added, enabled for architectures that support Rust.
- Abstractions have been proposed for use in Rust code for hardware pseudo-random number generator.
- The use of error codes without the prefix 'Error::' (e.g., 'return Err(EINVAL)') has been allowed to approach error code handling in C.
- A 'CString' type for own C strings has been added. The Formatter and Buffer types have been combined.
- The Bool and LockInfo traits have been added.
- The implementation of spinlocks has been simplified.
Source: opennet.ru
