Last year, Linux kernel developers suggested using Rust for new embedded code. In March 2021, this idea was partially implemented – an initial set of components for developing device drivers in Rust was included in the linux-next branch, on which Linux 5.13 will be based.
At the same time, documentation was published on using Rust in the Linux kernel with practical examples. Initially, Torvalds did not strongly oppose innovations (he does not do this even now). He said only that it is necessary to check how all these new items work in practice. Linus Torvalds has now reviewed the Rust drivers for Linux patches and made a number of critical comments.
The main problem, in his opinion, is the potential for “kernel panic” in some situations. This may be out of memory, where dynamic memory allocation operations may fail. Torvalds stated that such an approach in the core is fundamentally unacceptable. He even went further, saying that if the developers did not understand the problem, he would reject any code that tried to use this approach. The patching developer thinks the problem exists, but it can be solved.
The second problem, according to Torvalds, is the use of floating point or 128-bit types, which is not acceptable in environments such as the Linux kernel. This is even more critical than the previous point, since the base Rust library is one big blob – you cannot request only a few features in it, leaving the rest unattended. You have to use everything in a row, so it will not work to prevent the use of one or another problematic functionality. This problem can also be solved, but only by making changes to the rust compiler and accompanying libraries, despite the fact that the team does not have a clear strategy for implementing the modularity of the language libraries.
The developers provided an example driver, but Linus didn’t like it. Torvalds stated that this example is useless, adding advice to create a new driver that solves a real problem, rather than demonstrating theoretical capabilities.
Whatever it was, there is clearly Rust in Linux. For example, Google has already announced its intention to take part in an initiative to promote support for Rust in the Linux kernel. The company gave examples of the feasibility of implementing Rust to deal with problems that arise from errors when working with memory. The company also believes that Rust is quite ready to join C as another development language for Linux kernel components.