Skip to content

Latest commit

 

History

History
64 lines (46 loc) · 2.64 KB

README.md

File metadata and controls

64 lines (46 loc) · 2.64 KB

Linux kernel modules written in Rust

A collection of in-progress experimental Linux kernel modules written for the Rust for Linux project

To run the out-of-tree modules here you'll need to run a custom kernel with the changes developed in mdaverde/linux which will continuously be rebasing off the upstream R4L fork.

This project uses just and zx for project-wide task management but installing a specific module should just require make.

Current modules

The modules listed here have only been tested on an Ubuntu 21.04 x86_64 VM

  • current - logs (dmesg) information about the task context in which the module is running in (e.g. the module insert process)
  • proc_iter - logs attributes of every task_struct (except swapper/0) currently running
  • mem_layout - summarizes memory layout of the running kernel
  • bsa - custom wrapper around a few of the kernel page allocation APIs and logs physical continuity
  • kmalloc_box - custom alloc::Allocator (nightly) wrapped around kmalloc() and kfree() used with Box::try_new_in

mod_template/ is meant to be a starting template for future modules

Contributing

This repo is meant to be experimental and a showcase of potential LKM functionality with Rust. This project assumes you have all the same dependencies as R4L installed and can compile/install custom kernels.

Using Just

$ just --list
Available recipes:
    build module=DEFAULT_MODULE
    clean module=DEFAULT_MODULE
    create module
    default
    fmt
    rust-analyzer
    vars
$ just fmt # runs rustfmt */*.rs
$ just build # builds all modules
$ just build kmalloc_box # builds specific module
$ just create new_module # start new module

To install a specific module

With Make

$ cd ./current
$ make KERNELDIR=/to/rust/kernel LLVM=1 modules
$ sudo insmod ./current.ko # install module

Future ideas

  • procfs recreation
  • module stacking
  • use of no_std crates (through cargo?)

References