error-inject.c 425 B

12345678910111213141516171819
  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. "just_return_func:\n"
  8. " ret\n"
  9. ".size just_return_func, .-just_return_func\n"
  10. );
  11. void override_function_with_return(struct pt_regs *regs)
  12. {
  13. regs->ip = (unsigned long)&just_return_func;
  14. }
  15. NOKPROBE_SYMBOL(override_function_with_return);