error-inject.c 554 B

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