18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci#include <linux/error-injection.h> 48c2ecf20Sopenharmony_ci#include <linux/kprobes.h> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_civoid override_function_with_return(struct pt_regs *regs) 78c2ecf20Sopenharmony_ci{ 88c2ecf20Sopenharmony_ci /* 98c2ecf20Sopenharmony_ci * 'regs' represents the state on entry of a predefined function in 108c2ecf20Sopenharmony_ci * the kernel/module and which is captured on a kprobe. 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * When kprobe returns back from exception it will override the end 138c2ecf20Sopenharmony_ci * of probed function and directly return to the predefined 148c2ecf20Sopenharmony_ci * function's caller. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci instruction_pointer_set(regs, procedure_link_pointer(regs)); 178c2ecf20Sopenharmony_ci} 188c2ecf20Sopenharmony_ciNOKPROBE_SYMBOL(override_function_with_return); 19