KFI is a kernel module that injects faults into user process. The module directory contains the module and the makefile, the base diretory contains a Go library for using it, and kfi-inject is a command line tool for injecting faults. It currently follows these steps:
- Find the process's pid and task structs
- Send SIGSTOP to the process
- Sleep until the process enters stopped state
- Pick 2 random numbers
- Use the random numbers to pick a register to inject and which bit to flip
- Send SIGCONT to the process
The module was built and tested with kernel verion 3.4.112. It should be pretty portable, the only major thing that might change between versions is the pt_regs struct. If it doesn't immediatly work for your version, just change the values of regs_len and reg_names to the appropriate values for your kernel (These can be found in the arch/x86/include/asm/ptrace.h file of your kernel's source)
make
- insert (
make insert
will insert it with insmod. You could also usemake install
if you would like to use modprobe)
To download all of the Go tooling, run go get github.com/pixelrazor/kfi/...
NOTE: this requires you have the go binaries installed, and will place the binary in $GOPATH/bin
The autoci directory contains a program that can run a program, checkpoint it, inject faults, and benchmark it.
NOTE: This application is not meant to be widely used, and should not be considered a normal tool from the package. While it works just fine, the code is poorly structured, messy, and doesn't follow the best practices it could. Use this only if it interests you, otherwise steer clear.
The checkpointing feature relies on on blcr being set up on your system. If a program doesn't exit with error code 0 or abnormally terminates, it will attempt to restore from checkpoints, starting with the most recent one, until it completes successfully.
The fault injection feature relies on the KFI module and library being installed. The interval specified will be the rate of a randomly sampled exponential distribution.
Usage: autoci [options] program
Flag | Meaning |
---|---|
-kfi | Enable fault injection |
-k <duration> | Set the average time between faults |
-blcr | Enable checkpointing |
-b <duration> | Set the checkpointing interval |
-n <int> | The number of most recent checkpoints to keep (if blcr is enabled) |
-r <int> | The number of times to retry from a single checkpoint before deleting (if blcr is enabled) |
-t <duration> | Set a timeout. If execution lasts as long as this value, it will terminate the application |
Examples of valid durations:
10s, 1m5s, 4h, 1h6m7s, 12ms, 55ns, 101us