Josh Triplett, who works at Intel and is part of the committee overseeing the development of Crates.io, spoke at the Open Source Technology Summit. the working group aimed at bringing the Rust language up to parity with C in the area of systems programming.
In the working group currently being formed, Rust developers are collaborating with engineers from Intel to prepare specifications defining the functionality that needs to be implemented in Rust for systems programming. Systems programming often requires low-level manipulations, such as executing privileged processor instructions and obtaining detailed information about the processor's state. Among the already developed capabilities for Rust, support for unnamed structures, unions, inline assembly (the 'asm!' macro), and the BFLOAT16 floating-point format are noteworthy.
Josh believes that the future of systems programming belongs to Rust, while the C language, in modern realities, is competing for a place once held by Assembly.
Rust not only frees developers from the C language's inherent problems arising from low-level memory manipulation but also provides the ability to apply modern programming paradigms in development.
During of the presentation
Josh expressed the idea of adding the ability to develop drivers in Rust to the Linux kernel, which would allow for the creation of safe and higher-quality drivers with minimal effort, free from issues such as accessing memory after it has been freed, dereferencing null pointers, and buffer overflows.
Greg Kroah-Hartman, who is responsible for maintaining the stable branch of the Linux kernel, expressed his readiness to add a framework for developing drivers in Rust to the kernel if it offers real advantages over C, such as providing safe wrappers over the kernel API. Additionally, Greg considers this framework only as an option, not active by default, to avoid including Rust among the kernel's build dependencies.
It turns out that several teams are already working in this direction. For instance, developers from 'Fish in a Barrel' are involved. A toolkit for writing loadable modules for the Linux kernel in Rust, using layers of abstraction over kernel interfaces and structures to enhance security. The layers are automatically generated based on existing kernel header files using a utility. . The Clang compiler is used to build the layers. The modules built, in addition to the layers, utilize the staticlib package.
Simultaneously another project focused on developing drivers for embedded systems and Internet of Things devices, which also uses bindgen to generate layers based on kernel header files. The framework aims to enhance driver security without modifying the kernel—rather than creating additional isolation levels in the kernel for drivers, it proposes to catch issues at the compilation stage by using the safer Rust language. This approach is likely to be attractive to hardware manufacturers developing proprietary drivers quickly without thorough auditing.
Not all intended functionality has been implemented yet, but the framework is already quite usable and has been used to write a working driver for the LAN9512 USB Ethernet controller supplied with the Raspberry Pi 3 board. The existing smsc95xx driver, written in C, was used as a reference implementation for writing the Rust driver. It is noted that the module size and runtime overhead when developing a driver in Rust are minimal, allowing the framework to be applied to resource-constrained devices.
Source: opennet.ru
