Eliminating Calling a Child Node in the Call Stack

My task is to intercept specific system calls that are called from a specific directory. For each of these system calls, I make my own implementation, which looks like this:

int my_syscall(args) {
  struct task_struct * cur_task = current;
  if(check_dir(cur_task)) {
    do_smth;
    n = orig_sys_call(args);
    do_smth;
    return n;
  }
  else {
    return orig_sys_call(args);
  }
}

      

The question is: is it possible to somehow modify the else

( return orig_sys_call(args)

) section so that once executed, orig_sys_call(args)

it returns directly to the caller function rather than returning to my implementation?

I want to know if I can use this with language tools and not for compiler optimization. I figured out from the answer to my previous question, GCC Return optimiztion , that call or sibling optimization could be done, so that's a different question now.

+3


source to share





All Articles