Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
601d75d8
Commit
601d75d8
authored
Mar 21, 2018
by
Howard McLauchlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
automatically include mm.h, remove redundant includes from _example.txt
parent
ac7c154c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
tools/inject.py
tools/inject.py
+1
-0
tools/inject_example.txt
tools/inject_example.txt
+6
-7
No files found.
tools/inject.py
View file @
601d75d8
...
...
@@ -426,6 +426,7 @@ struct pid_struct {
def
_generate_program
(
self
):
# leave out auto includes for now
self
.
program
+=
"#include <linux/mm.h>
\
n
"
for
include
in
(
self
.
args
.
include
or
[]):
self
.
program
+=
"#include <%s>
\
n
"
%
include
...
...
tools/inject_example.txt
View file @
601d75d8
...
...
@@ -9,7 +9,7 @@ As a simple example, let's say you wanted to fail all mounts. While we cannot
fail the mount() syscall directly (a patch is in the works), we can easily
fail do_mount() calls like so:
# ./inject.py kmalloc -v
-I 'linux/fs.h'
'do_mount()'
# ./inject.py kmalloc -v 'do_mount()'
The first argument indicates the mode (or what to fail). Appropriate headers are
specified. The verbosity flag prints the generated program.
...
...
@@ -20,7 +20,7 @@ allocate memory, as expected.
Whenever a predicate is missing, an implicit "(true)" is inserted. The example
above can be explicitly written as:
# ./inject.py kmalloc -v
-I 'linux/fs.h'
'(true) => do_mount()(true)'
# ./inject.py kmalloc -v '(true) => do_mount()(true)'
The "(true)" without an associated function is a predicate for the error
injection mechanism of the current mode. In the case of kmalloc, the predicate
...
...
@@ -39,7 +39,7 @@ Now let's say we want to be a bit more specific; suppose you want to fail
kmalloc() from mount_subtree() when called from btrfs_mount(). This will fail
only btrfs mounts:
# ./inject.py kmalloc -
I 'linux/fs.h' -
v 'mount_subtree() => btrfs_mount()'
# ./inject.py kmalloc -v 'mount_subtree() => btrfs_mount()'
Attempting to mount btrfs filesystem during the execution of this command will
yield an error, but other filesystems will be fine.
...
...
@@ -49,8 +49,7 @@ there is a BUG_ON in btrfs_prepare_close_one_device() at fs/btrfs/volumes.c:1002
To hit this, we can use the following:
# ./inject.py kmalloc -v -I 'linux/mm.h' 'btrfs_alloc_device()
=> btrfs_close_devices()'
# ./inject.py kmalloc -v 'btrfs_alloc_device() => btrfs_close_devices()'
While the script was executing, I mounted and unmounted btrfs, causing a
segfault on umount(since that satisfied the call path indicated). A look at
...
...
@@ -68,8 +67,8 @@ very often, we can distinguish distinct calls with function arguments. Let's say
we want to fail the dentry allocation of a file creatively named 'bananas'. We
can do the following:
# ./inject.py kmalloc -v
-I 'linux/fs.h' 'd_alloc_parallel(struct dentry
*parent, const struct
qstr *name)(STRCMP(name->name, 'bananas'))'
# ./inject.py kmalloc -v
'd_alloc_parallel(struct dentry *parent, const struct
qstr *name)(STRCMP(name->name, 'bananas'))'
While this script is executing, any operation that would cause a dentry
allocation where the name is 'bananas' fails, as expected.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment