October 25, 2020

Linux kernel will be written in Rust programming language?

2 min read

Recently, Microsoft intends to choose Rust as a secure alternative to C and C++. Rust is a system programming language led by Mozilla, focusing on security, speed, and concurrency. It was originally a research project of Mozilla for more secure and more Quickly rewrite the Firefox browser. Microsoft said it considers Rust. In addition to its ability to write system-level programs in a memory-safe manner, performance, granular control, and a healthy community are all reasons why Rust is favored. About 70% of Microsoft’s vulnerabilities are still memory security issues every year. If these programs are written in Rust, then 70% of the security issues are probably not there.

rust

The developer asked the Linux kernel stable maintainer Greg Kroah-Hartman about Rust, Greg expressed his willingness to accept drivers for developing the Linux kernel with Rust, but only if:

“1) for now it wasn’t enabled by default (even if you did “make allyesconfig”) so that people don’t *need* Rust to build the kernel, and 2) it shows real benefits beyond writing C, such as safe wrappers for kernel APIs.”

However, there are developers who have pointed out the inconvenience of using the Rust implementation driver. The Linux kernel does not guarantee the stability of the API/ABI, so it is difficult to design a generic Rust interface. At least it is almost impossible to make it suitable for all versions of Linux. Many C language features do not have corresponding Rust support. For example, constructing a structure with a bitfield seems to be unachievable.

Of course, most developers agree that Rust is a promising language for kernel programming, but it requires everyone’s efforts to achieve it.