nixmodule

Crates.ionixmodule
lib.rsnixmodule
version0.4.2
sourcesrc
created_at2022-04-15 03:01:15.505709
updated_at2023-03-06 16:45:46.672197
descriptionSimple qemu wrapper to automatically test out-of-tree linux kernel modules across multiple kernel versions.
homepagehttps://github.com/landhb/nixmodule
repositoryhttps://github.com/landhb/nixmodule
max_upload_size
id568205
size159,522
Bradley Landherr (landhb)

documentation

README

NixModule cargo-badge

Simple qemu wrapper to automatically test out-of-tree linux kernel modules across multiple kernel versions. The provided images all have KASAN to aide your development.

cargo install nixmodule

Example below running it against a single kernel, running without arguments tests against every kernel in your nixmodule-config.toml:

Pre-Built Kernels

Check nixmodule-config.toml for an example configuration using all of these images.

Version BzImage Headers LTS?
5.17.2 bZimage Headers
5.15.33 bZimage Headers Yes
5.10.110 bZimage Headers Yes
5.8.9 bZimage Headers
5.4.188 bZimage Headers Yes
4.19.237 bZimage Headers Yes
4.14.275 bZimage Headers Yes
4.9.309 bZimage Headers Yes
4.4.302 bZimage Headers Yes

Pre-Built Disk Images

ImgName Link SSH Key
Cornerstone Image Key
Syzkaller Debian Buster Image Key
Syzkaller Debian Stretch Image Key

Using Other Kernels

Use the packing script

KERNEL=4.14.275 ./scripts/package.sh

This builds the required bzImage and an archive linux-$VERSION-headers.tar.gz containing the headers/module info required to build an out-of-tree kernel module.

Then add the new kernel to your configuration file nixmodule-config.toml:

[[kernels]]
version = "4.19.237"
url_base = "https://files.sboc.dev"
headers = "linux-headers/linux-4.19.237-headers.tar.gz" 
kernel = "linux-kernels/bzImage-linux-4.19.237"
runner = "qemu-system-x86_64"

[kernels.disk]
name = "stretch"
url_base = "https://files.sboc.dev"
path = "images/stretch/stretch.img"
sshkey = "images/stretch/stretch.id_rsa"
boot = "/dev/sda"

You can optionally disable kvm with:

kvm = false

And increase the boot timeout with:

timeout = 600

Without kvm you'll likely need to increase the default the timeout.

Using Other Disk Images

Fill out the [kernels.disk] entry for the kernel you'd like to use the new disk with:

[kernels.disk]
name = "stretch"
url_base = "https://files.sboc.dev"
path = "images/stretch/stretch.img"
sshkey = "images/stretch/stretch.id_rsa"
boot = "/dev/sda"

Boot should contain the partition to boot from. This is passed to qemu to append as kernel arguments:

-append "console=ttyS0 root=$BOOT earlyprintk=serial net.ifnames=0 nokaslr"
Commit count: 34

cargo fmt