Programming with Rust for the FreeBSD kernel
Writing drivers in Rust instead of C? After Linux, this should now also be possible in FreeBSD.
FreeBSD developer David Young has written code that allows kernel modules for FreeBSD to be written in Rust instead of C. The reasons for this are the same as for the Linux kernel, which is soon to receive official Rust support: Like C, Rust allows low-level programming, but offers modern protection mechanisms against many programming errors that easily occur in C – especially memory errors, which are responsible for many vulnerabilities in software are responsible.
The crate (Rust’s nickname for library) kernel-sys provides Rust bindings for the FreeBSD kernel header files, which define the kernel interfaces for drivers. The crate bsd kernel provides abstractions that make for a more Rust-friendly API. A very simple demo module shows that writing BSD drivers in Rust basically works with it. The next step must now be the development of a simple, useful kernel module in Rust, writes Young.
Young provides the code with a concise guide on GitHub. In the blog post Writing FreeBSD Kernel Modules in Rust he explains his reasons and the technical details.