Rust-for-Linux rootkit detection kernel module
A Rust kernel module that caught the symbol-hiding LKM rootkit Diamorphine by checking where syscall table entries point.
- Field
- Security · 2025
- Period
- Dec 18, 2025 – Jan 15, 2026
- Team
- Layer7 end-of-term project, team of three
- Role
- PM, dev environment, detection module
- Setup
- Arch Linux, kernel 6.18.0, Rust nightly
- Tags
Overview
rust_rkscan is a Linux kernel module written with Rust-for-Linux that detects LKM rootkits hiding themselves by hooking system calls. In a C kernel module, one memory mistake in the detection code can panic the kernel, so we chose Rust, whose ownership and borrowing rules reject that class of bug at compile time.
It was a three-person end-of-term project for Layer7, a security club. As PM I shaped the idea with the team, built the development environment and wrote the detection module.
Environment
We started on Ubuntu Server 24.04 under QEMU/KVM, but Rust-for-Linux builds kept failing on bindgen version conflicts, mismatched cargo and apt packages, and an old LLVM. I rebuilt the environment on an Arch Linux VM, which ships the latest kernel and Rust nightly right away.
- OS: Arch Linux, kernel 6.18.0, Rust 1.94.0-nightly, LLVM/Clang
- Target rootkit: Diamorphine, a public LKM rootkit
Detection design
Diamorphine removes itself from lsmod, filters its own symbols out of /proc/kallsyms, and hooks the getdents, getdents64 and kill system calls. The module therefore checks in two stages.

- Signature check: look up known symbols such as
diamorphine_initandhacked_getdentswithkallsyms_lookup_name. - Behavior check: read the current address of key system calls from
sys_call_table, and flag a hook when an address falls outside the kernel.textrange, in module memory.
With KASLR on, addresses changed on every boot and the .text range check became unreliable. For the experiment we turned KASLR off and built the function pointers from fixed addresses read in /proc/kallsyms.
Results
On a clean system both checks pass and the module prints System Clear.

After loading Diamorphine with insmod and scanning again, the signature check still finds nothing because Diamorphine filters kallsyms. The behavior check finds that getdents (78), getdents64 (217) and kill (62) now point outside the .text range (0xffffffff81000000 to 0xffffffff8231f750), into module memory at 0xffffffffc000xxxx, and prints Rootkit Detected!.

Against a rootkit that hides its symbols, the signature check failed and the behavior check, which looks at the real addresses in the syscall table, caught it. It showed in practice that a kernel module written in Rust can do the same kernel-level inspection as a C module.
Limits and next steps
- The module only detects. It does not restore hooked system calls or block malicious modules from loading.
- Next steps:
- Compare detection rates and limits against other rootkits such as Reptile and Suterusu
- Write our own rootkit that fixes Diamorphine's weak spots and evades this module, then harden the detector against it
- Build a C module with the same features and compare performance and safety
- The
.textrange should also be computed at runtime so the check works with KASLR on.