diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81db967..faff3d2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,10 @@ name: test -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: env: CARGO_TERM_COLOR: always diff --git a/src/ptrace/mock_ptrace.rs b/src/ptrace/mock_ptrace.rs index a1b8505..596447b 100644 --- a/src/ptrace/mock_ptrace.rs +++ b/src/ptrace/mock_ptrace.rs @@ -46,13 +46,13 @@ impl Tracer for MockPtrace { fn get_ptrace( &mut self, - data_ptr: *mut from_c::ptrace_syscall_info, + data_ptr: *mut from_c::struct_ptrace_syscall_info, ) -> Result { // safety: mock_ptrace is used only in fuzz-testing of the library, not at production build let slice = unsafe { std::slice::from_raw_parts_mut( data_ptr as *mut u8, - mem::size_of::(), + mem::size_of::(), ) }; diff --git a/src/ptrace/syscall_ptrace.rs b/src/ptrace/syscall_ptrace.rs index 2aafa23..6d03d60 100644 --- a/src/ptrace/syscall_ptrace.rs +++ b/src/ptrace/syscall_ptrace.rs @@ -241,7 +241,7 @@ impl Tracer for SyscallPtrace { let ret_bytes = unsafe { libc::ptrace( - from_c::PTRACE_GET_SYSCALL_INFO, + from_c::__ptrace_request_PTRACE_GET_SYSCALL_INFO, libc::pid_t::from(Pid::from_raw(self.current_pid as i32)), mem::size_of::(), data_ptr, diff --git a/src/wrapper.h b/src/wrapper.h index 0eadb66..785a1a4 100644 --- a/src/wrapper.h +++ b/src/wrapper.h @@ -1,5 +1,37 @@ // Tracing -#include +#include + +// From strace +# if defined HAVE_STRUCT_PTRACE_SYSCALL_INFO +typedef struct ptrace_syscall_info struct_ptrace_syscall_info; +# elif defined HAVE_STRUCT___PTRACE_SYSCALL_INFO +typedef struct __ptrace_syscall_info struct_ptrace_syscall_info; +# else +#include +struct ptrace_syscall_info { + uint8_t op; + uint8_t pad[3]; + uint32_t arch; + uint64_t instruction_pointer; + uint64_t stack_pointer; + union { + struct { + uint64_t nr; + uint64_t args[6]; + } entry; + struct { + int64_t rval; + uint8_t is_error; + } exit; + struct { + uint64_t nr; + uint64_t args[6]; + uint32_t ret_data; + } seccomp; + }; +}; +typedef struct ptrace_syscall_info struct_ptrace_syscall_info; +# endif // Syscalls #include