bpf/error-inject/kprobes: Clear current_kprobe and enable preempt in kprobe
Clear current_kprobe and enable preemption in kprobe even if pre_handler returns !0. This simplifies function override using kprobes. Jprobe used to require to keep the preemption disabled and keep current_kprobe until it returned to original function entry. For this reason kprobe_int3_handler() and similar arch dependent kprobe handers checks pre_handler result and exit without enabling preemption if the result is !0. After removing the jprobe, Kprobes does not need to keep preempt disabled even if user handler returns !0 anymore. But since the function override handler in error-inject and bpf is also returns !0 if it overrides a function, to balancing the preempt count, it enables preemption and reset current kprobe by itself. That is a bad design that is very buggy. This fixes such unbalanced preempt-count and current_kprobes setting in kprobes, bpf and error-inject. Note: for powerpc and x86, this removes all preempt_dis...
Showing
- arch/arc/kernel/kprobes.c 3 additions, 2 deletionsarch/arc/kernel/kprobes.c
- arch/arm/probes/kprobes/core.c 5 additions, 5 deletionsarch/arm/probes/kprobes/core.c
- arch/arm64/kernel/probes/kprobes.c 5 additions, 5 deletionsarch/arm64/kernel/probes/kprobes.c
- arch/ia64/kernel/kprobes.c 4 additions, 9 deletionsarch/ia64/kernel/kprobes.c
- arch/mips/kernel/kprobes.c 2 additions, 2 deletionsarch/mips/kernel/kprobes.c
- arch/powerpc/kernel/kprobes-ftrace.c 6 additions, 13 deletionsarch/powerpc/kernel/kprobes-ftrace.c
- arch/powerpc/kernel/kprobes.c 5 additions, 2 deletionsarch/powerpc/kernel/kprobes.c
- arch/s390/kernel/kprobes.c 4 additions, 3 deletionsarch/s390/kernel/kprobes.c
- arch/sh/kernel/kprobes.c 4 additions, 3 deletionsarch/sh/kernel/kprobes.c
- arch/sparc/kernel/kprobes.c 4 additions, 3 deletionsarch/sparc/kernel/kprobes.c
- arch/x86/kernel/kprobes/core.c 4 additions, 0 deletionsarch/x86/kernel/kprobes/core.c
- arch/x86/kernel/kprobes/ftrace.c 3 additions, 6 deletionsarch/x86/kernel/kprobes/ftrace.c
- kernel/fail_function.c 0 additions, 3 deletionskernel/fail_function.c
- kernel/trace/trace_kprobe.c 3 additions, 8 deletionskernel/trace/trace_kprobe.c
Loading
Please register or sign in to comment