Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 540adea3 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Alexei Starovoitov
Browse files

error-injection: Separate error-injection from kprobe



Since error-injection framework is not limited to be used
by kprobes, nor bpf. Other kernel subsystems can use it
freely for checking safeness of error-injection, e.g.
livepatch, ftrace etc.
So this separate error-injection framework from kprobes.

Some differences has been made:

- "kprobe" word is removed from any APIs/structures.
- BPF_ALLOW_ERROR_INJECTION() is renamed to
  ALLOW_ERROR_INJECTION() since it is not limited for BPF too.
- CONFIG_FUNCTION_ERROR_INJECTION is the config item of this
  feature. It is automatically enabled if the arch supports
  error injection feature for kprobe or ftrace etc.

Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Reviewed-by: default avatarJosef Bacik <jbacik@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 66665ad2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ config HAVE_OPTPROBES
config HAVE_KPROBES_ON_FTRACE
	bool

config HAVE_KPROBE_OVERRIDE
config HAVE_FUNCTION_ERROR_INJECTION
	bool

config HAVE_NMI
+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ config X86
	select HAVE_KERNEL_XZ
	select HAVE_KPROBES
	select HAVE_KPROBES_ON_FTRACE
	select HAVE_KPROBE_OVERRIDE
	select HAVE_FUNCTION_ERROR_INJECTION
	select HAVE_KRETPROBES
	select HAVE_KVM
	select HAVE_LIVEPATCH			if X86_64
+13 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_ERROR_INJECTION_H
#define _ASM_ERROR_INJECTION_H

#include <linux/compiler.h>
#include <linux/linkage.h>
#include <asm/ptrace.h>
#include <asm-generic/error-injection.h>

asmlinkage void just_return_func(void);
void override_function_with_return(struct pt_regs *regs);

#endif /* _ASM_ERROR_INJECTION_H */
+0 −14
Original line number Diff line number Diff line
@@ -1183,17 +1183,3 @@ int arch_trampoline_kprobe(struct kprobe *p)
{
	return 0;
}

asmlinkage void override_func(void);
asm(
	".type override_func, @function\n"
	"override_func:\n"
	"	ret\n"
	".size override_func, .-override_func\n"
);

void arch_kprobe_override_function(struct pt_regs *regs)
{
	regs->ip = (unsigned long)&override_func;
}
NOKPROBE_SYMBOL(arch_kprobe_override_function);
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ lib-y += memcpy_$(BITS).o
lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o insn-eval.o
lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o
lib-$(CONFIG_FUNCTION_ERROR_INJECTION)	+= error-inject.o

obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o

Loading