Linux Audio

Check our new training course

Loading...
v6.8
 1// SPDX-License-Identifier: GPL-2.0
 2
 3#include <linux/linkage.h>
 4#include <linux/error-injection.h>
 5#include <linux/kprobes.h>
 6#include <linux/objtool.h>
 7
 8asmlinkage void just_return_func(void);
 9
10asm(
11	".text\n"
12	".type just_return_func, @function\n"
13	".globl just_return_func\n"
14	ASM_FUNC_ALIGN
15	"just_return_func:\n"
16		ANNOTATE_NOENDBR
17		ASM_RET
18	".size just_return_func, .-just_return_func\n"
19);
20
21void override_function_with_return(struct pt_regs *regs)
22{
23	regs->ip = (unsigned long)&just_return_func;
24}
25NOKPROBE_SYMBOL(override_function_with_return);
v4.17
 1// SPDX-License-Identifier: GPL-2.0
 2
 
 3#include <linux/error-injection.h>
 4#include <linux/kprobes.h>
 
 5
 6asmlinkage void just_return_func(void);
 7
 8asm(
 
 9	".type just_return_func, @function\n"
10	".globl just_return_func\n"
 
11	"just_return_func:\n"
12	"	ret\n"
 
13	".size just_return_func, .-just_return_func\n"
14);
15
16void override_function_with_return(struct pt_regs *regs)
17{
18	regs->ip = (unsigned long)&just_return_func;
19}
20NOKPROBE_SYMBOL(override_function_with_return);