Project Description

Rust language is on the way to enter linux kernel, use this hackweek to explore and learn what this could bring us (or not).

Goal for this Hackweek

No fixed goals, learn as much as possible, but some topics for inspiration:

  • set up compilation and testing environment
  • try to understand some aspects of the implementation
    • locking primitives
    • unsafe memory operations
    • passing C <-> rust data structures
  • higher level aspects
    • limitations of current implementation, eg. can other subsystems be adapted for rust
    • differences when designing interconnected data structures C vs rust
  • example drivers and code
    • analyze existing example driver
    • try to write own
    • analyze generated assembly object code

Resources

  • https://doc.rust-lang.org/book/ rust language documentation
  • v7 https://lore.kernel.org/lkml/20220523020209.11810-1-ojeda@kernel.org/
  • https://github.com/Rust-for-Linux/linux.git -- linux sources with rust patches
  • rust kernel API https://rust-for-linux.github.io/docs/kernel/
  • TBD slack/IRC channel for discussions
  • TBD lwn.net articles about the progress

Skill level:

  • rust coding - beginner to expert
  • rust enthusiasm - skeptic to fanatic
  • linux kernel - intermediate to expert

Howtos

Rust

You can use rustup tool to install the versions manually (package available in openSUSE), we require 1.61, this is also available in openSUSE.

```

rustup toolchain install 1.61

rustup default 1.61

rustup toolchain list

stable-x8664-unknown-linux-gnu nightly-x8664-unknown-linux-gnu 1.61-x86_64-unknown-linux-gnu (default) ```

The linux+rust support

  • must read -- https://github.com/Rust-for-Linux/linux/blob/rust/Documentation/rust/quick-start.rst
  • use this -- development repository (https://github.com/Rust-for-Linux/linux.git)
  • do not use -- linux-next (https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git) -- rust patchset is there but compilation does not work with 1.60,

Linux

Checkout the Rust-for-Linux git tree, all make commands need to be run as make LLVM=1 so the llvm support is detected even for configuration phase

  • make LLVM=1 defconfig
  • scripts/enable CONFIG_RUST and make LLVM=1 oldconfig
  • make LLVM=1 menuconfig, navigate to General to enable rust and to Kernel hacking to enable all examples
  • make LLVM=1 -j 16 to start build

Drivers, config options:

  • ANDROIDBINDERIPC_RUST
  • GPIOPL061RUST
  • SAMPLES_RUST -- check all
  • RUST_* namespace, various safety and debugging options

Looking for hackers with the skills:

rust linux kernel

This project is part of:

Hack Week 21

Activity

  • over 2 years ago: fanyadan liked this project.
  • over 2 years ago: jzerebecki liked this project.
  • over 2 years ago: dmdiss liked this project.
  • over 2 years ago: dsterba added keyword "kernel" to this project.
  • over 2 years ago: dsterba added keyword "rust" to this project.
  • over 2 years ago: dsterba added keyword "linux" to this project.
  • over 2 years ago: dsterba started this project.
  • over 2 years ago: dsterba originated this project.

  • Comments

    Be the first to comment!

    Similar Projects

    Implement a CLI tool for Trento - trentoctl by nkopliku

    Description

    Implement a trentoctl CLI for...


    Better diff'ing experience by MSirringhaus

    Description

    For diff-ing directories, I usu...


    Kanidm: A safe and modern IDM system by firstyear

    Kanidm is an IDM system written in Rust for mod...


    Grapesss: a physical Shamir's Secret Sharing application [ESP32-C3 + Mobile] by ecandino

    <img src="https://i.imgur.com/ndfnzHo.png" alt=...


    Hacking on sched_ext by flonnegren

    Description

    Sched_ext upstream has some i...


    Linux Security and Practice by r1chard-lyu

    Description

    This project focuses on discove...


    toptop - a top clone written in Go by dshah

    Description

    toptop is a clone of Linux's ...


    Explore simple and distro indipendent declarative Linux starting on Tumbleweed or Arch Linux by janvhs

    Description

    Inspired by [mkosi](https://g...


    Testing and adding GNU/Linux distributions on Uyuni by juliogonzalezgil

    Join the Gitter channel! [https://gitter.im/uy...


    Contributing to Linux Kernel security by pperego

    Description

    A couple of weeks ago, I foun...


    Linux on Cavium CN23XX cards by tsbogend

    Before Cavium switched to ARM64 CPUs they devel...


    Hacking on sched_ext by flonnegren

    Description

    Sched_ext upstream has some i...


    Officially Become a Kernel Hacker! by m.crivellari

    Description

    My studies as well my spare tim...


    Contributing to Linux Kernel security by pperego

    Description

    A couple of weeks ago, I foun...


    Model checking the BPF verifier by shunghsiyu

    Project Description

    BPF verifier plays a ...