^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/error-injection.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/kprobes.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) asmlinkage void just_return_func(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) asm(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) ".text\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) ".type just_return_func, @function\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ".globl just_return_func\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) "just_return_func:\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) " ret\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) ".size just_return_func, .-just_return_func\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) void override_function_with_return(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) regs->ip = (unsigned long)&just_return_func;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) NOKPROBE_SYMBOL(override_function_with_return);