Miguel Ojeda, the author of the Rust-for-Linux project, proposed for consideration by the Linux kernel developers a fourth version of components for developing device drivers in Rust. Support for Rust is seen as experimental but has already been approved for inclusion in the linux-next branch and is sufficiently developed to begin work on creating abstraction layers over the kernel subsystems, as well as writing drivers and modules. The development is financed by Google and the Internet Security Research Group (ISRG), which is the founder 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.
In the new version of the patches, the elimination of comments made during the discussion of the first, second, and third versions of the patches continues. In the new version:
- The transition to using the stable release Rust 1.58.0 as the reference compiler has been made. The necessary changes for the project that have not yet been included in the main set of Rust tools include the flag ‘-Zsymbol-mangling-version=v0’ (expected in Rust 1.59.0) and the ‘maybe_uninit_extra’ mode (expected in Rust 1.60.0).
- Automatic checks for the availability of the appropriate Rust toolchain have been added, and capabilities for testing Rust support in the system have been expanded.
- New abstractions have been proposed for accessing device ID tables from Rust code (‘IdArray’ and ‘IdTable’).
- Layers for accessing timer-related functions (clock framework) have been added.
- Drivers for platforms are now defined through the implementation of traits.
- A new macro for simplifying platform driver registration has been added, along with a proposed new template for a basic driver.
- Macros for ‘dev_*’ structures have been added.
- Methods ‘{read,write}*_relaxed’ have been added for the type IoMem.
- The FileOpener property has been removed to simplify file operations.
- A parameter ‘ThisModule’ has been added to the list of arguments passed during driver registration.
- A template has been proposed for creating kernel modules in Rust.
Source: opennet.ru
