1inject(8) System Manager's Manual inject(8)
2
3
4
6 inject - injects appropriate error into function if input call chain
7 and predicates are satisfied. Uses Linux eBPF/bcc.
8
9
10
12 inject -h [-I header] [-P probability] [-v] [-c count] <mode> <spec>
13
14
15
17 inject injects errors into specified kernel functionality when a given
18 call chain and associated predicates are satisfied.
19
20 WARNING: This tool injects failures into key kernel functions and may
21 crash the kernel. You should know what you're doing if you're using
22 this tool.
23
24 This makes use of a Linux 4.16 feature (bpf_override_return())
25
26 Since this uses BPF, only the root user can use this tool.
27
28
29
31 -h Print usage message.
32
33 -v Display the generated BPF program, for debugging or modifica‐
34 tion.
35
36 -I header
37 Necessary headers to be included.
38
39 -P probability
40 Optional probability of failure, default 1.
41
42 -c count
43 Number of errors to inject before stopping, default never stops.
44
45
46
48 kmalloc
49 Make the following function indicate failure
50 int should_failslab(struct kmem_cache *s, gfp_t gfpflags)
51
52
53 bio Make the following function indicate failure
54 int should_fail_bio(struct bio *bio)
55
56
57 alloc_page
58 Make the following function indicate failure
59 bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int
60 order)
61
62
63
65 FUNCTION([ARGS])[(TEST)] [=> ...]
66
67 A list of predicates separated by "=>". A predicate is a function sig‐
68 nature (name and arguments) in a call stack and a test on the func‐
69 tion's arguments.
70
71 Missing predicates are implicitly true. Missing tests are implicitly
72 true. Specifying the function arguments is optional if the test does
73 not use them. If the error injection function is not listed as the
74 first predicate, it is implicitly added.
75
76 Functions are listed in the reverse order that they are called, ie. if
77 a() calls b(), the spec would be "b() => a()".
78
79
80
82 CONFIG_BPF, CONFIG_BPF_KPROBE_OVERRIDE, bcc
83
84
85
87 inject kmalloc -v 'SyS_mount()'
88
89 inject kmalloc -v 'mount_subtree() => btrfs_mount()'
90
91 inject -P 0.5 -c 100 alloc_page "should_fail_alloc_page(gfp_t gfp_mask, unsigned int order) (order == 1) => qlge_refill_bq()"
92
93 Please see the output of '-h' and tools/inject_example.txt for more
94 examples.
95
96
97
99 This is from bcc.
100
101 https://github.com/iovisor/bcc
102
103 Also look in the bcc distribution for a companion _examples.txt file
104 containing example usage, output, and commentary for this tool.
105
106
107
109 Linux
110
111
112
114 Unstable - in development.
115
116
117
119 Howard McLauchlan
120
121
122
123USER COMMANDS 2018-03-16 inject(8)