Loading .gitlab-ci.yml +3 −3 Original line number Diff line number Diff line Loading @@ -64,9 +64,9 @@ unit-test-job: # This job runs in the test stage. - ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall getpriority --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpriority --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpriority --reps 1 --verbose --always_syscall artifacts: expire_in: 1 week when: always Loading src/eval.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ #include <libsyscall_intercept_hook_point.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/resource.h> void start_interception() __attribute__((constructor)); void Loading @@ -23,6 +25,11 @@ hook_kill(int pid, int sig) { return 42; } int hook_getpriority(int which, id_t who) { return 42; } inline int hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* result) { Loading @@ -48,6 +55,10 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = hook_kill(static_cast<int>(arg0), static_cast<int>(arg1)); break; case SYS_getpriority: *result = hook_getpriority(static_cast<int>(arg0), static_cast<id_t>(arg1)); break; default: // ignore any other syscalls, i.e.: pass them on to the kernel // (syscalls forwarded to the kernel that return are logged in Loading @@ -66,7 +77,7 @@ hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, int was_hooked = 1; if (syscall_number == SYS_openat || syscall_number == SYS_getpid || syscall_number == SYS_kill) { if (syscall_number == SYS_openat || syscall_number == SYS_getpid || syscall_number == SYS_kill || syscall_number == SYS_getpriority) { was_hooked = hook(syscall_number, arg0, arg1, arg2, arg3, arg4, arg5, syscall_return_value); } return was_hooked; Loading src/opendevnull.cpp +19 −19 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <sys/syscall.h> #include <unistd.h> #include <signal.h> #include <sys/resource.h> #include <libsyscall_intercept_hook_point.h> Loading Loading @@ -58,7 +59,7 @@ main(int argc, char* argv[]) { syscall = argv[++i]; } else { std::cerr << "Error: --syscall requires an argument (open|getpid|kill|getpagesize)" << "Error: --syscall requires an argument (open|getpid|kill|getpriority)" << std::endl; return 1; } Loading Loading @@ -134,32 +135,31 @@ main(int argc, char* argv[]) { }; // getpagesyze() is used to determine the page size, pre - post auto pre_size = []() { int ret = getpagesize(); // getpriority() is used to determine the page size, pre - post auto pre_prio = []() { int ret = getpriority(0,0); if(verbose) { std::cout << "getpagesize() returned " << ret << std::endl; std::cout << "getpriority() returned " << ret << std::endl; } if(always_syscall) { syscall_no_intercept(SYS_getpagesize); syscall_no_intercept(SYS_getpriority, 0, 0); } return ret; }; auto post_size = [](int) { auto post_prio = [](int) { }; double time_taken = 0; if(syscall == "open") { time_taken = measure_syscall_time(pre_open, post_open, reps); } else if(syscall == "getpid") { time_taken = measure_syscall_time(pre_getpid, post_getpid, reps); } else if(syscall == "kill") { time_taken = measure_syscall_time(pre_kill, post_kill, reps); } else if(syscall == "getpagesize") { time_taken = measure_syscall_time(pre_size, post_size, reps); } else { } else if(syscall == "getpriority") { time_taken = measure_syscall_time(pre_prio, post_prio, reps); } else { std::cerr << "Error: Unsupported syscall '" << syscall << "'" << std::endl; return 1; Loading Loading
.gitlab-ci.yml +3 −3 Original line number Diff line number Diff line Loading @@ -64,9 +64,9 @@ unit-test-job: # This job runs in the test stage. - ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall kill --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpagesize --reps 1 --verbose --always_syscall - ${BUILD_PATH}/opendevnull --syscall getpriority --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpriority --reps 1 --verbose - LD_PRELOAD=${BUILD_PATH}/libeval_intercept.so ${BUILD_PATH}/opendevnull --syscall getpriority --reps 1 --verbose --always_syscall artifacts: expire_in: 1 week when: always Loading
src/eval.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ #include <libsyscall_intercept_hook_point.h> #include <sys/syscall.h> #include <sys/types.h> #include <sys/resource.h> void start_interception() __attribute__((constructor)); void Loading @@ -23,6 +25,11 @@ hook_kill(int pid, int sig) { return 42; } int hook_getpriority(int which, id_t who) { return 42; } inline int hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5, long* result) { Loading @@ -48,6 +55,10 @@ hook(long syscall_number, long arg0, long arg1, long arg2, long arg3, long arg4, *result = hook_kill(static_cast<int>(arg0), static_cast<int>(arg1)); break; case SYS_getpriority: *result = hook_getpriority(static_cast<int>(arg0), static_cast<id_t>(arg1)); break; default: // ignore any other syscalls, i.e.: pass them on to the kernel // (syscalls forwarded to the kernel that return are logged in Loading @@ -66,7 +77,7 @@ hook_guard_wrapper(long syscall_number, long arg0, long arg1, long arg2, int was_hooked = 1; if (syscall_number == SYS_openat || syscall_number == SYS_getpid || syscall_number == SYS_kill) { if (syscall_number == SYS_openat || syscall_number == SYS_getpid || syscall_number == SYS_kill || syscall_number == SYS_getpriority) { was_hooked = hook(syscall_number, arg0, arg1, arg2, arg3, arg4, arg5, syscall_return_value); } return was_hooked; Loading
src/opendevnull.cpp +19 −19 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <sys/syscall.h> #include <unistd.h> #include <signal.h> #include <sys/resource.h> #include <libsyscall_intercept_hook_point.h> Loading Loading @@ -58,7 +59,7 @@ main(int argc, char* argv[]) { syscall = argv[++i]; } else { std::cerr << "Error: --syscall requires an argument (open|getpid|kill|getpagesize)" << "Error: --syscall requires an argument (open|getpid|kill|getpriority)" << std::endl; return 1; } Loading Loading @@ -134,32 +135,31 @@ main(int argc, char* argv[]) { }; // getpagesyze() is used to determine the page size, pre - post auto pre_size = []() { int ret = getpagesize(); // getpriority() is used to determine the page size, pre - post auto pre_prio = []() { int ret = getpriority(0,0); if(verbose) { std::cout << "getpagesize() returned " << ret << std::endl; std::cout << "getpriority() returned " << ret << std::endl; } if(always_syscall) { syscall_no_intercept(SYS_getpagesize); syscall_no_intercept(SYS_getpriority, 0, 0); } return ret; }; auto post_size = [](int) { auto post_prio = [](int) { }; double time_taken = 0; if(syscall == "open") { time_taken = measure_syscall_time(pre_open, post_open, reps); } else if(syscall == "getpid") { time_taken = measure_syscall_time(pre_getpid, post_getpid, reps); } else if(syscall == "kill") { time_taken = measure_syscall_time(pre_kill, post_kill, reps); } else if(syscall == "getpagesize") { time_taken = measure_syscall_time(pre_size, post_size, reps); } else { } else if(syscall == "getpriority") { time_taken = measure_syscall_time(pre_prio, post_prio, reps); } else { std::cerr << "Error: Unsupported syscall '" << syscall << "'" << std::endl; return 1; Loading