Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add intercept hook after kernel syscall completes #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/libsyscall_intercept_hook_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ extern int (*intercept_hook_point)(long syscall_number,

extern void (*intercept_hook_point_clone_child)(void);
extern void (*intercept_hook_point_clone_parent)(long pid);
extern void (*intercept_hook_point_post_kernel)(long syscall_number,
long arg0, long arg1,
long arg2, long arg3,
long arg4, long arg5,
long result);

/*
* syscall_no_intercept - syscall without interception
Expand Down
22 changes: 22 additions & 0 deletions src/intercept.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ void (*intercept_hook_point_clone_child)(void)
__attribute__((visibility("default")));
void (*intercept_hook_point_clone_parent)(long)
__attribute__((visibility("default")));
void (*intercept_hook_point_post_kernel)(long syscall_number,
long arg0, long arg1,
long arg2, long arg3,
long arg4, long arg5,
long result)
__attribute__((visibility("default")));

bool debug_dumps_on;

Expand Down Expand Up @@ -655,6 +661,22 @@ intercept_routine(struct context *context)
desc.args[3],
desc.args[4],
desc.args[5]);


/*
* some users might want to execute code after a syscall has
* been forwarded to the kernel (for example, to check its
* return value).
*/
if (intercept_hook_point_post_kernel != NULL)
intercept_hook_point_post_kernel(desc.nr,
desc.args[0],
desc.args[1],
desc.args[2],
desc.args[3],
desc.args[4],
desc.args[5],
result);
}

intercept_log_syscall(patch, &desc, KNOWN, result);
Expand Down