Skip to content

Commit

Permalink
Add new targeted error injection tool
Browse files Browse the repository at this point in the history
bpf_override_return is a very powerful mechanism for error injection,
with the caveat that it requires whitelisting of the functions to be
overriden.

inject.py will take a call chain and optional set of predicates as
input, and inject the appropriate error when both the call chain and all
predicates are satisfied.

Signed-off-by: Howard McLauchlan <[email protected]>
  • Loading branch information
Howard McLauchlan committed Mar 17, 2018
1 parent d6f716b commit ef4154b
Show file tree
Hide file tree
Showing 4 changed files with 581 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pair of .c and .py files, and some are directories of files.
- tools/[funcslower](tools/funcslower.py): Trace slow kernel or user function calls. [Examples](tools/funcslower_example.txt).
- tools/[gethostlatency](tools/gethostlatency.py): Show latency for getaddrinfo/gethostbyname[2] calls. [Examples](tools/gethostlatency_example.txt).
- tools/[hardirqs](tools/hardirqs.py): Measure hard IRQ (hard interrupt) event time. [Examples](tools/hardirqs_example.txt).
- tools/[inject](tools/inject.py): Targeted error injection with call chain and predicates [Examples](tools/inject_example.txt).
- tools/[killsnoop](tools/killsnoop.py): Trace signals issued by the kill() syscall. [Examples](tools/killsnoop_example.txt).
- tools/[llcstat](tools/llcstat.py): Summarize CPU cache references and misses by process. [Examples](tools/llcstat_example.txt).
- tools/[mdflush](tools/mdflush.py): Trace md flush events. [Examples](tools/mdflush_example.txt).
Expand Down
47 changes: 47 additions & 0 deletions man/man8/inject.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.TH inject 8 "2018-03-16" "USER COMMANDS"
.SH NAME
inject \- injects appropriate error into function if input call chain and
predicates are satisfied. Uses Linux eBPF/bcc.
.SH SYNOPSIS
.B trace -h [-I header] [-v]
.SH DESCRIPTION
inject injects errors into specified kernel functionality when a given call
chain and associated predicates are satsified.

This makes use of a Linux 4.16 feature (bpf_override_return())

Additionally, use of the kmalloc failure mode is only possible with

commit f7174d08a5fc ("mm: make should_failslab always available for
fault injection")

which is in mm-tree but not yet in mainline (as of 4.16-rc5).

Since this uses BPF, only the root user can use this tool.
.SH REQUIREMENTS
CONFIG_BPF, CONFIG_BPF_KPROBE_OVERRIDE, bcc
.SH OPTIONS
.TP
\-h
Print usage message.
.TP
\-v
Display the generated BPF program, for debugging or modification.
.TP
\-I header
Necessary headers to be included.
.SH EXAMPLES
Please see inject_example.txt
.SH SOURCE
This is from bcc.
.IP
https://github.com/iovisor/bcc
.PP
Also look in the bcc distribution for a companion _examples.txt file containing
example usage, output, and commentary for this tool.
.SH OS
Linux
.SH STABILITY
Unstable - in development.
.SH AUTHOR
Howard McLauchlan
Loading

0 comments on commit ef4154b

Please sign in to comment.