New version of patches for the Linux kernel with support for the Rust language

Miguel Ojeda, the author of the Rust-for-Linux project, proposed the release of v5 components for developing device drivers in the Rust language for consideration by Linux kernel developers. This is the sixth edition of the patches, taking into account the first version, 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 writing drivers and modules. The development is funded by Google and the ISRG (Internet Security Research Group), which is the founder of the Let's Encrypt project and promotes HTTPS and the development of technologies to improve Internet security.

Recall that the proposed changes make it possible to use Rust as a second language for developing drivers and kernel modules. Rust support is presented as an option that is not enabled by default and does not result in the inclusion of Rust among the required build dependencies for the kernel. Using Rust to develop drivers will allow you to create safer and better drivers with minimal effort, free from problems such as accessing a memory area after it is freed, dereferencing null pointers, and buffer overruns.

Memory-safe handling is provided in Rust at compile time through reference checking, keeping track of object ownership and object lifetime (scope), as well as through evaluation of the correctness of memory access during code execution. Rust also provides protection against integer overflows, requires mandatory initialization of variable values ​​before use, handles errors better in the standard library, applies the concept of immutable references and variables by default, offers strong static typing to minimize logical errors.

The new version of the patches continues to eliminate the comments made during the discussion of the first, second, third, fourth and fifth editions of the patches. In the new version:

  • The toolkit has been updated to release Rust 1.59.0. A variant of the alloc library is also synchronized with the new version of Rust, eliminating the possible generation of a β€œpanic” state when errors occur, such as out of memory. The ability to use assembler inserts (β€œfeature(global_asm)”) has been stabilized.
  • Added support for creating host programs in Rust that are used during kernel compilation.
  • Instead of delivering pre-generated target platform specification files, they are dynamically generated based on kernel configuration.
  • Added HAVE_RUST kernel parameter to enable for architectures that support Rust.
  • Abstractions are proposed for use in Rust code for a hardware pseudo-random number generator.
  • Allowed the use of error codes without the "Error::" prefix (for example, "return Err(EINVAL)") to approximate the handling of error codes in C.
  • Added "CString" type for custom C-strings. The Formatter and Buffer types have been combined.
  • Added Bool and LockInfo types.
  • The implementation of spin locks has been simplified.

Source: opennet.ru

Add a comment