Information was recently released about the Kerla project, which is being developed as an operating system kernel written in the Rust language. The code is distributed under the Apache 2.0 and MIT licenses. The project is being developed by Japanese developer Seiya Nuta, known for creating the Resea microkernel operating system, written in C language.
The new kernel aims initially ensure compatibility with the Linux kernel at the ABI level, which will allow unmodified binaries built for Linux to run in a Kerla-based environment.
Kerla is a monolithic operating system kernel created from scratch in Rust. At the current stage of development, Kerla can only be run on systems with x86_64 architecture and implements basic system calls like write, stat, mmap, pipe and poll, supports signals, unnamed pipes and context switches. Calls like fork, wait4 and execve provide to control the processes. There is support for tty and pseudo-terminals (pty). Among the initramfs file systems (used to mount the root FS), tmpfs and devfs are still supported.
A network stack with support for TCP and UDP sockets is also provided, Based on the smoltcp library. The developer has prepared a boot environment that works in QEMU or Firecracker VM with the driver virtio-net, to which you can already connect via SSH. Musl is used as a system library and BusyBox is used as a user utility. Based on Docker, a build system has been prepared that allows you to create your own initramfs boot with the Kerla kernel.
So far, few details have been provided about its new kernel, but what draws the most attention to Kerla's features is the fact that it is written in Rust. So does writing it in Rust have any advantages over other languages or over existing code? Many answered yes to this question, emphasizing the memory security benefits that language provides.
It is also provided when evaluating the accuracy of memory accesses at run time. What's more, Mozilla believes that Rust offers protection against integer overflows, requires mandatory initialization of variable values before use, adopts the concept of references and immutable variables by default, offers strong static typing to minimize logical errors, and simplifies input processing through matching of patterns.
Among the advantages, we highlight the integrated tools to evaluate the quality of the code and creating unit tests that can be run not only on real hardware, but also on QEMU. Basically, Mozilla finds Rust easier to debug as the compiler will reject errors. However, the coves did point to some drawbacks with Rust.
“As with C ++, it is almost impossible to write idiomatic Rust without using templates, so it has bloated binaries and slow compile times. All of these compile-time checks also come at a cost. Also, if you rewrite something, you lose the old mature codebase, and there is no way you can produce a codebase of similar quality in a reasonable amount of time; it is much better to extend, rather than rewrite, the program in Rust. It's better to extend the program rather than rewrite it in Rust, ”says a software engineer.
According to its creator, it is for this reason that Linux developers, in particular Linus Torvalds himself, they rejected the idea of rewriting the entire kernel in Rust.
“Do some work to create secure links, then write the additional code in Rust and you can still enjoy that mature code. (That's what Linux does, there are efforts to add the ability to write a kernel module in Rust), ”he added. Linux developers have been exploring the possibilities of writing certain new kernel modules using the Rust language for about three years. This gave rise to the »Rust for Linux« project.
Finally, if you are interested in knowing more about it, you can consult the details In the following link.