Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | |
Olivier Deprez | 92d4c21 | 2022-12-06 15:05:30 +0100 | [diff] [blame^] | 3 | #include <linux/linkage.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 4 | #include <linux/error-injection.h> |
| 5 | #include <linux/kprobes.h> |
| 6 | |
| 7 | asmlinkage void just_return_func(void); |
| 8 | |
| 9 | asm( |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 10 | ".text\n" |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 11 | ".type just_return_func, @function\n" |
| 12 | ".globl just_return_func\n" |
| 13 | "just_return_func:\n" |
Olivier Deprez | 92d4c21 | 2022-12-06 15:05:30 +0100 | [diff] [blame^] | 14 | ASM_RET |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 15 | ".size just_return_func, .-just_return_func\n" |
| 16 | ); |
| 17 | |
| 18 | void override_function_with_return(struct pt_regs *regs) |
| 19 | { |
| 20 | regs->ip = (unsigned long)&just_return_func; |
| 21 | } |
| 22 | NOKPROBE_SYMBOL(override_function_with_return); |