error-inject.c 563 B

123456789101112131415161718
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/error-injection.h>
  3. #include <linux/kprobes.h>
  4. void override_function_with_return(struct pt_regs *regs)
  5. {
  6. /*
  7. * 'regs' represents the state on entry of a predefined function in
  8. * the kernel/module and which is captured on a kprobe.
  9. *
  10. * When kprobe returns back from exception it will override the end
  11. * of probed function and directly return to the predefined
  12. * function's caller.
  13. */
  14. instruction_pointer_set(regs, procedure_link_pointer(regs));
  15. }
  16. NOKPROBE_SYMBOL(override_function_with_return);