Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit a526e12

Browse files
Add intercept hook after kernel syscall completes
1 parent 7031a8f commit a526e12

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

include/libsyscall_intercept_hook_point.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ extern int (*intercept_hook_point)(long syscall_number,
5959

6060
extern void (*intercept_hook_point_clone_child)(void);
6161
extern void (*intercept_hook_point_clone_parent)(long pid);
62+
extern void (*intercept_hook_point_post_kernel)(long syscall_number,
63+
long arg0, long arg1,
64+
long arg2, long arg3,
65+
long arg4, long arg5,
66+
long result);
6267

6368
/*
6469
* syscall_no_intercept - syscall without interception

src/intercept.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ void (*intercept_hook_point_clone_child)(void)
7171
__attribute__((visibility("default")));
7272
void (*intercept_hook_point_clone_parent)(long)
7373
__attribute__((visibility("default")));
74+
void (*intercept_hook_point_post_kernel)(long syscall_number,
75+
long arg0, long arg1,
76+
long arg2, long arg3,
77+
long arg4, long arg5,
78+
long result)
79+
__attribute__((visibility("default")));
7480

7581
bool debug_dumps_on;
7682

@@ -655,6 +661,22 @@ intercept_routine(struct context *context)
655661
desc.args[3],
656662
desc.args[4],
657663
desc.args[5]);
664+
665+
666+
/*
667+
* some users might want to execute code after a syscall has
668+
* been forwarded to the kernel (for example, to check its
669+
* return value).
670+
*/
671+
if (intercept_hook_point_post_kernel != NULL)
672+
intercept_hook_point_post_kernel(desc.nr,
673+
desc.args[0],
674+
desc.args[1],
675+
desc.args[2],
676+
desc.args[3],
677+
desc.args[4],
678+
desc.args[5],
679+
result);
658680
}
659681

660682
intercept_log_syscall(patch, &desc, KNOWN, result);

0 commit comments

Comments
 (0)