GitXplorerGitXplorer
m

kernel-modules-rust

public
22 stars
2 forks
0 issues

Commits

List of commits on branch main.
Unverified
a35228b474adadd0528e27e1a6942ebd99c4bd1d

KernelModule trait signature

mmdaverde committed 3 years ago
Unverified
77c88d6da6f71fcfd85e10ba36da21b1df3718a6

update kernel fork link

mmdaverde committed 3 years ago
Unverified
569c5a43dc9a603c3048a2977625bae6efed8f9d

[proc_iter] display kernel threads' comm

mmdaverde committed 3 years ago
Unverified
21693f6da0823ebaab0d2025ffcd6dc0802a9657

[current] moves run fn into struct impl

mmdaverde committed 3 years ago
Unverified
52905b3670f37f924a1fe76d7a6811fdbbb357ac

convention of starting with module! declaration

mmdaverde committed 3 years ago
Unverified
860cc107edc7e87d7559cda63ffdd565201e155d

no_std idea

mmdaverde committed 3 years ago

README

The README file for this repository.

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