forked from mirrors/linux
		
	 7cd01b08d3
			
		
	
	
		7cd01b08d3
		
	
	
	
	
		
			
			We implement regs_set_return_value() and override_function_with_return() for this purpose. On powerpc, a return from a function (blr) just branches to the location contained in the link register. So, we can just update pt_regs rather than redirecting execution to a dummy function that returns. Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
		
			
				
	
	
		
			16 lines
		
	
	
	
		
			470 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			16 lines
		
	
	
	
		
			470 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0+
 | |
| 
 | |
| #include <linux/error-injection.h>
 | |
| #include <linux/kprobes.h>
 | |
| #include <linux/uaccess.h>
 | |
| 
 | |
| void override_function_with_return(struct pt_regs *regs)
 | |
| {
 | |
| 	/*
 | |
| 	 * Emulate 'blr'. 'regs' represents the state on entry of a predefined
 | |
| 	 * function in the kernel/module, captured on a kprobe. We don't need
 | |
| 	 * to worry about 32-bit userspace on a 64-bit kernel.
 | |
| 	 */
 | |
| 	regs->nip = regs->link;
 | |
| }
 | |
| NOKPROBE_SYMBOL(override_function_with_return);
 |