1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun #include <linux/error-injection.h> 4*4882a593Smuzhiyun #include <linux/kprobes.h> 5*4882a593Smuzhiyun override_function_with_return(struct pt_regs * regs)6*4882a593Smuzhiyunvoid override_function_with_return(struct pt_regs *regs) 7*4882a593Smuzhiyun { 8*4882a593Smuzhiyun /* 9*4882a593Smuzhiyun * 'regs' represents the state on entry of a predefined function in 10*4882a593Smuzhiyun * the kernel/module and which is captured on a kprobe. 11*4882a593Smuzhiyun * 12*4882a593Smuzhiyun * When kprobe returns back from exception it will override the end 13*4882a593Smuzhiyun * of probed function and directly return to the predefined 14*4882a593Smuzhiyun * function's caller. 15*4882a593Smuzhiyun */ 16*4882a593Smuzhiyun instruction_pointer_set(regs, procedure_link_pointer(regs)); 17*4882a593Smuzhiyun } 18*4882a593Smuzhiyun NOKPROBE_SYMBOL(override_function_with_return); 19