Last active
September 19, 2018 02:15
-
-
Save jhgorse/0d03049853d4ad4971f637894ad3be56 to your computer and use it in GitHub Desktop.
Inject page allocation failures for a specific kernel module, linux 4x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inject page allocation failures only for a specific module | |
# Requires debugfs and kernel fault injection framework enabled | |
FAILTYPE=fail_page_alloc | |
module=$1 | |
if [ -z $module ] | |
then | |
echo "Usage: $0 <modulename>" | |
exit 1 | |
fi | |
modprobe $module | |
if [ ! -d /sys/module/$module/sections ] | |
then | |
echo Module $module is not loaded | |
exit 1 | |
fi | |
echo 0 > /sys/kernel/debug/$FAILTYPE/require-start | |
echo 0xffffffff > /sys/kernel/debug/$FAILTYPE/require-end | |
#cat /sys/module/$module/sections/.text > /sys/kernel/debug/$FAILTYPE/require-start | |
#cat /sys/module/$module/sections/.data > /sys/kernel/debug/$FAILTYPE/require-end | |
#echo "0x"$(grep afs_linux_write_begin /proc/kallsyms | awk '{print $1}') > /sys/kernel/debug/$FAILTYPE/require-start | |
#echo "0x"$(grep -A 1 afs_linux_write_begin /proc/kallsyms | awk '{print $1}' | tail -n 1) > /sys/kernel/debug/$FAILTYPE/require-end | |
# task-filter /proc/<pid>/make-it-fail==1 | |
echo N > /sys/kernel/debug/$FAILTYPE/task-filter | |
echo 100 > /sys/kernel/debug/$FAILTYPE/probability | |
echo 10 > /sys/kernel/debug/$FAILTYPE/interval | |
echo 10 > /sys/kernel/debug/$FAILTYPE/times | |
echo 0 > /sys/kernel/debug/$FAILTYPE/space | |
echo 2 > /sys/kernel/debug/$FAILTYPE/verbose | |
echo 0 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait | |
echo 0 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-highmem | |
echo 10 > /sys/kernel/debug/$FAILTYPE/stacktrace-depth | |
trap "echo 0 > /sys/kernel/debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT | |
echo "Injecting errors into the module $module... (interrupt to stop)" | |
sleep 1000000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment