diff options
author | Guo Ren <guoren@linux.alibaba.com> | 2020-07-28 16:30:46 +0000 |
---|---|---|
committer | Guo Ren <guoren@linux.alibaba.com> | 2020-07-31 01:52:07 +0000 |
commit | 71e193d7cbcfc988c3802e15261bd807171adb6b (patch) | |
tree | b339e8d97c2a6094ac17bc85ea306bff7edb983f /arch/csky/lib | |
parent | a5447fb9b32eb33b2f0f09a63e4852b46af5b056 (diff) | |
download | linux-71e193d7cbcfc988c3802e15261bd807171adb6b.tar.bz2 |
csky: Add support for function error injection
Inspired by the commit 42d038c4fb00 ("arm64: Add support for function
error injection"), this patch supports function error injection for
csky.
This patch mainly support two functions: one is regs_set_return_value()
which is used to overwrite the return value; the another function is
override_function_with_return() which is to override the probed
function returning and jump to its caller.
Test log:
cd /sys/kernel/debug/fail_function/
echo sys_clone > inject
echo 100 > probability
echo 1 > interval
ls /
[ 108.644163] FAULT_INJECTION: forcing a failure.
[ 108.644163] name fail_function, interval 1, probability 100, space 0, times 1
[ 108.647799] CPU: 0 PID: 104 Comm: sh Not tainted 5.8.0-rc5+ #46
[ 108.648384] Call Trace:
[ 108.649339] [<8005eed4>] walk_stackframe+0x0/0xf0
[ 108.649679] [<8005f16a>] show_stack+0x32/0x5c
[ 108.649927] [<8040f9d2>] dump_stack+0x6e/0x9c
[ 108.650271] [<80406f7e>] should_fail+0x15e/0x1ac
[ 108.650720] [<80118ba8>] fei_kprobe_handler+0x28/0x5c
[ 108.651519] [<80754110>] kprobe_breakpoint_handler+0x144/0x1cc
[ 108.652289] [<8005d6da>] trap_c+0x8e/0x110
[ 108.652816] [<8005ce8c>] csky_trap+0x5c/0x70
-sh: can't fork: Invalid argument
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/csky/lib')
-rw-r--r-- | arch/csky/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/csky/lib/error-inject.c | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/arch/csky/lib/Makefile b/arch/csky/lib/Makefile index 078e2d5f32e1..7fbdbb2c4d12 100644 --- a/arch/csky/lib/Makefile +++ b/arch/csky/lib/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only lib-y := usercopy.o delay.o +obj-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o diff --git a/arch/csky/lib/error-inject.c b/arch/csky/lib/error-inject.c new file mode 100644 index 000000000000..c15fb36fe067 --- /dev/null +++ b/arch/csky/lib/error-inject.c @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/error-injection.h> +#include <linux/kprobes.h> + +void override_function_with_return(struct pt_regs *regs) +{ + instruction_pointer_set(regs, regs->lr); +} +NOKPROBE_SYMBOL(override_function_with_return); |