// SPDX-License-Identifier: GPL-2.0-or-later /* * x86 implementation of rethook. Mostly copied from arch/x86/kernel/kprobes/core.c. */ #include <linux/bug.h> #include <linux/rethook.h> #include <linux/kprobes.h> #include <linux/objtool.h> #include "kprobes/common.h" __visible void arch_rethook_trampoline_callback(struct pt_regs *regs); #ifndef ANNOTATE_NOENDBR #define ANNOTATE_NOENDBR #endif /* * When a target function returns, this code saves registers and calls * arch_rethook_trampoline_callback(), which calls the rethook handler. */ asm …; NOKPROBE_SYMBOL(arch_rethook_trampoline); /* * Called from arch_rethook_trampoline */ __used __visible void arch_rethook_trampoline_callback(struct pt_regs *regs) { … } NOKPROBE_SYMBOL(arch_rethook_trampoline_callback); /* * arch_rethook_trampoline() skips updating frame pointer. The frame pointer * saved in arch_rethook_trampoline_callback() points to the real caller * function's frame pointer. Thus the arch_rethook_trampoline() doesn't have * a standard stack frame with CONFIG_FRAME_POINTER=y. * Let's mark it non-standard function. Anyway, FP unwinder can correctly * unwind without the hint. */ STACK_FRAME_NON_STANDARD_FP(arch_rethook_trampoline); /* This is called from rethook_trampoline_handler(). */ void arch_rethook_fixup_return(struct pt_regs *regs, unsigned long correct_ret_addr) { … } NOKPROBE_SYMBOL(arch_rethook_fixup_return); void arch_rethook_prepare(struct rethook_node *rh, struct pt_regs *regs, bool mcount) { … } NOKPROBE_SYMBOL(arch_rethook_prepare);