Rust for Linux

Project for adding Rust language to the Linux kernel
  • Community contributors
  • Miguel Ojeda
Initial releaseOctober 1, 2022; 23 months ago (2022-10-01)Repositorygithub.com/Rust-for-Linux/linuxWritten inRustOperating systemLinuxAvailable inEnglishLicenseGPL-2.0-only with Linux-syscall-note.Websitehttps://rust-for-linux.com/

Rust for Linux is an ongoing project started in 2020 to add Rust as a programming language that can be used within the Linux kernel software, which has been written using C and assembly only. This project aims to leverage Rust's memory safety to reduce bugs when writing kernel drivers.[1] Progress has been slower than hoped by both Rust advocates and Linus Torvalds, lead of the Linux kernel project.[2] In December 2023 the first drivers written in Rust were accepted, and released in version 6.8.[3][4]

History

The Linux kernel has been primarily written in C and assembly languages since its first release in 1991. Around 1997, the addition of C++ was considered and experimented upon for two weeks before being scrapped.[5] Rust was created in 2006 and combines the performance of low-level programming languages (such as C) with a focus on memory safety and a user-friendly tool set and syntax.[6]

An example Linux external loadable kernel module created using the Rust language was published by Taesoo Kim in 2013.[7][8]

The Rust for Linux project was announced in 2020 in the Linux kernel mailing list with goal of adding Rust as a programming language that could be used within the Linux project.[9] At the Open Source Summit 2022, Linus Torvalds stated that the incorporation of the project's work could begin as soon as the Linux 5.20 release, later named as Linux 6.0.[10] The first release candidate for Linux 6.0 was created on 14 August 2022, without Rust support. In the release notes for Linux 6.0-rc1, Torvalds expressed his intention for adding Rust support, "I actually was hoping that we'd get some of the first rust infrastructure, and the multi-gen LRU VM, but neither of them happened this time around."[11][12] On 19 September 2022, an article from ZDNet revealed an email from Linus Torvalds stating that "Unless something odd happens, it [Rust] will make it into 6.1".[13]

In October 2022, a pull request for accepting the implementation for Rust for Linux was approved by Torvalds.[14] As of Linux 6.1, support was intentionally left minimal in order to allow developers to test the feature.[15]

Rust for Linux developers created a new library "pinned-init" to safely and fallibly initialize memory that must not be relocated.[3] It was first included in Linux 6.4,[16] and been improved in latter versions.[3]

Linux 6.10 included RISCV processor architecture support for Rust.[17]

In July 2024 a change was accepted into Linux to support multiple Rust versions for the first time, allowing compiling using both 1.78 (Released 2 May, 2024) and 1.79 (Released 13 June, 2024).[18]

As of August 2024[update], Rust for Linux depends on unstable features of the Rust compiler.[1]

Usage

Linux kernel contains the following Rust components:

  • rnull, a drop-in replacement for the null block device driver[3][19]
  • Asix AX88772A and Realtek Generic FE-GE physical layer network drivers[3][4][20][21]

Drivers scheduled for inclusion in Linux kernel:

  • QR code DRM panic handler[18]

Other notable projects using Rust in Linux include:

  • tarfs, a tar filesystem[3][22]
  • NVMe device driver[3]
  • Android Binder IPC driver[9][3][23]
  • Asahi Linux's Apple silicon AGX GPU DRM driver[24][3][25]
  • PuzzleFS, a container filesystem[3][26][22]
  • Read-only Ext2 filesystem[22]
  • Nova, intended to create a Rust nouveau Nvidia GPU driver, is being developed on the Freedesktop project infrastructure[27][28]

See also

References

  1. ^ a b Vaughan-Nichols, Steven. "Rust in Linux: Where we are and where we're going next". zdnet. Retrieved 31 August 2024.
  2. ^ "Linus Torvalds talks AI, Rust adoption, and why the Linux kernel is 'the only thing that matters'". zdnet. 23 August 2024. Retrieved 31 August 2024.
  3. ^ a b c d e f g h i j Li, Hongyu; Guo, Liwei; Yang, Yexuan; Wang, Shangguang; Xu, Mengwei (1 July 2024). "An Empirical Study of Rust-for-Linux: The Success, Dissatisfaction, and Compromise". usenix. ;login:. Retrieved 4 September 2024.
  4. ^ a b Das, Ankush (11 March 2024). "Linux Kernel 6.8 Released! Goes Big On Hardware Support". news.itsfoss.com. Retrieved 4 September 2024.
  5. ^ Claburn, Thomas (2022-06-23). "Linus Torvalds says Rust is coming to the Linux kernel". The Register. Archived from the original on 2022-07-28. Retrieved 2022-07-25.
  6. ^ Perkel, Jeffrey M. (2020-12-01). "Why scientists are turning to Rust". Nature. 588 (7836): 185–186. Bibcode:2020Natur.588..185P. doi:10.1038/d41586-020-03382-2. PMID 33262490. S2CID 227251258. Archived from the original on 2022-05-06. Retrieved 2022-08-04.
  7. ^ Vaughan-Nichols, Steven J. (5 October 2022). "Rust in the Linux Kernel". thenewstack.io. Retrieved 31 August 2024.
  8. ^ Ojeda, Miguel (23 June 2022). "Memory Safety for the World's Largest Software Project". Retrieved 31 August 2024.
  9. ^ a b Simone, Sergio De (2021-04-27). "Using Rust to Write Safe and Correct Linux Kernel Drivers". InfoQ. Archived from the original on 2022-09-22. Retrieved 2022-08-04.
  10. ^ Vaughan-Nichols, Steven (2022-06-27). "Linus Torvalds is cautiously optimistic about bringing Rust into Linux kernel's next release". ZDNet. Archived from the original on 2022-08-12. Retrieved 2022-08-04.
  11. ^ Tung, Liam (2022-08-15). "Linux 6.0 arrives with performance improvements and more Rust coming". ZDNet. Archived from the original on 2022-09-07. Retrieved 2022-09-07.
  12. ^ Torvalds, Linus (2022-08-14). "Linux 6.0-rc1". LWN.net. Retrieved 2022-09-07.
  13. ^ Vaughan-Nichols, Steven (2022-09-19). "Linus Torvalds: Rust will go into Linux 6.1". ZDNET. Archived from the original on 2023-01-19. Retrieved 2022-09-20.
  14. ^ Proven, Liam (2022-10-05). "Linux 6.1: Rust to hit mainline kernel". The Register. Archived from the original on 2022-10-12. Retrieved 2022-10-12.
  15. ^ Corbet, Jonathan. "Next steps for Rust in the kernel". LWN.net. Archived from the original on 2023-06-08. Retrieved 2023-05-03.
  16. ^ Larabel, Michael. "More Rust Code Readied For Linux 6.4". phoronix.com. Retrieved 31 August 2024.
  17. ^ Knop, Dirk (July 27, 2024). "Linux-Kernel 6.10: Verbesserte Dateisysteme und neue Treiber". heise.de. Retrieved 31 August 2024.
  18. ^ a b Leemhuis, Thorsten (Aug 29, 2024). "Linux kernel gets "blue screens" with QR code". heise.de. Retrieved 31 August 2024.
  19. ^ Larabel, Michael. "Rust Null Block Driver Published To Begin Experimenting With Rust For Linux Storage". phoronix.com. Retrieved 31 August 2024.
  20. ^ Larabel, Michael. "The First Rust-Written Network PHY Driver Set To Land In Linux 6.8". phoronix.com. Retrieved 31 August 2024.
  21. ^ "Rust abstractions for network PHY drivers". Retrieved 31 August 2024.
  22. ^ a b c Larabel, Michael. "Microsoft Engineer Ports EXT2 File-System Driver To Rust". phoronix.com. Retrieved 31 August 2024.
  23. ^ Filho, Wedson Almeida (April 14, 2021). "Rust in the Linux kernel". Google Security Blog. Retrieved 31 August 2024.
  24. ^ Corbet, Jonathan (2 September 2024). "Whither the Apple AGX graphics driver?". LWN.net. Retrieved 5 September 2024.
  25. ^ Larabel, Michael. "Initial Rust DRM Abstractions, AGX Apple DRM Driver Posted For Review". phoronix.com. Retrieved 31 August 2024.
  26. ^ Larabel, Michael. "PuzzleFS Continues Striving To Be The Best File-System For Containers". phoronix.com. Retrieved 31 August 2024.
  27. ^ Das, Ankush (21 March 2024). "Red Hat Unveils a Rust-based 'Nova' Driver: A Better Nouveau for Nvidia GPUs". news.itsfoss.com. Retrieved 4 September 2024.
  28. ^ Larabel, Michael. "Red Hat's Long, Rust'ed Road Ahead For Nova As Nouveau Driver Successor". phoronix.com. Retrieved 31 August 2024.
  • v
  • t
  • e
Organization
Kernel
Support
Technical
Debugging
Startup
ABIs
APIs
Kernel
System Call
Interface
In-kernel
Userspace
Daemons,
File systems
Wrapper
libraries
Components
Variants
Virtualization
Adoption
Range
of use
Adopters
  • icon Linux portal
  • Free and open-source software portal
  • Category
  • v
  • t
  • e
Linux kernel
Controversies
Distributions
Organizations
Adoption
Media
Professional related certifications
  • icon Linux portal
  • Free and open-source software portal
  • Category