error-inject.c 454 B

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