Skip to content

Commit 4e5821f

Browse files
Pre and post syscall hooks
1 parent a6b44da commit 4e5821f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

linux-user/syscall.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13193,9 +13193,12 @@ struct syshook_ret {
1319313193
uint64_t retval;
1319413194
bool skip_syscall;
1319513195
};
13196-
struct syshook_ret (*libafl_syscall_hook)(int, uint64_t, uint64_t, uint64_t,
13197-
uint64_t, uint64_t, uint64_t,
13198-
uint64_t, uint64_t);
13196+
struct syshook_ret (*libafl_pre_syscall_hook)(int, uint64_t, uint64_t, uint64_t,
13197+
uint64_t, uint64_t, uint64_t,
13198+
uint64_t, uint64_t);
13199+
uint64_t (*libafl_post_syscall_hook)(uint64_t, int, uint64_t, uint64_t,
13200+
uint64_t, uint64_t, uint64_t, uint64_t,
13201+
uint64_t, uint64_t);
1319913202

1320013203
//// --- End LibAFL code ---
1320113204

@@ -13230,8 +13233,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
1323013233

1323113234
//// --- Begin LibAFL code ---
1323213235

13233-
if (libafl_syscall_hook) {
13234-
struct syshook_ret hook_ret = libafl_syscall_hook(num,
13236+
if (libafl_pre_syscall_hook) {
13237+
struct syshook_ret hook_ret = libafl_pre_syscall_hook(num,
1323513238
(uint64_t)arg1,
1323613239
(uint64_t)arg2,
1323713240
(uint64_t)arg3,
@@ -13252,6 +13255,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
1325213255
arg5, arg6, arg7, arg8);
1325313256

1325413257
//// --- Begin LibAFL code ---
13258+
13259+
if (libafl_post_syscall_hook) {
13260+
ret = (abi_ulong)libafl_post_syscall_hook((uint64_t)ret, num,
13261+
(uint64_t)arg1,
13262+
(uint64_t)arg2,
13263+
(uint64_t)arg3,
13264+
(uint64_t)arg4,
13265+
(uint64_t)arg5,
13266+
(uint64_t)arg6,
13267+
(uint64_t)arg7,
13268+
(uint64_t)arg8);
13269+
}
13270+
1325513271
after_syscall:
1325613272
//// --- End LibAFL code ---
1325713273

0 commit comments

Comments
 (0)