From 1e3c4a468a0e936a16c9b6a5f96f577502f2653a Mon Sep 17 00:00:00 2001 From: Peter Zhang Date: Wed, 13 Nov 2024 01:20:44 +0000 Subject: [PATCH] Move common Linux ptrace definitions to linux_like/mod.rs --- libc-test/semver/android.txt | 39 ------ libc-test/semver/linux-gnu-x86_64.txt | 2 - libc-test/semver/linux-gnu.txt | 7 - libc-test/semver/linux.txt | 12 ++ src/unix/linux_like/android/mod.rs | 36 ----- src/unix/linux_like/emscripten/mod.rs | 31 ----- src/unix/linux_like/linux/gnu/b32/mod.rs | 4 - .../linux_like/linux/gnu/b64/aarch64/mod.rs | 2 - .../linux/gnu/b64/loongarch64/mod.rs | 1 - .../linux_like/linux/gnu/b64/mips64/mod.rs | 1 - .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 2 - .../linux_like/linux/gnu/b64/riscv64/mod.rs | 1 - src/unix/linux_like/linux/gnu/b64/s390x.rs | 2 - .../linux_like/linux/gnu/b64/sparc64/mod.rs | 2 - .../linux_like/linux/gnu/b64/x86_64/mod.rs | 11 -- src/unix/linux_like/linux/gnu/mod.rs | 107 --------------- src/unix/linux_like/linux/mod.rs | 1 - src/unix/linux_like/linux/musl/mod.rs | 32 ----- src/unix/linux_like/linux/uclibc/mod.rs | 39 ------ src/unix/linux_like/mod.rs | 125 ++++++++++++++++++ 20 files changed, 137 insertions(+), 320 deletions(-) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 4a91a63c8fa3b..2dfdffbca0b91 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -1958,43 +1958,6 @@ PTHREAD_MUTEX_NORMAL PTHREAD_MUTEX_RECURSIVE PTHREAD_RWLOCK_INITIALIZER PTHREAD_STACK_MIN -PTRACE_ATTACH -PTRACE_CONT -PTRACE_DETACH -PTRACE_EVENT_CLONE -PTRACE_EVENT_EXEC -PTRACE_EVENT_EXIT -PTRACE_EVENT_FORK -PTRACE_EVENT_SECCOMP -PTRACE_EVENT_STOP -PTRACE_EVENT_VFORK -PTRACE_EVENT_VFORK_DONE -PTRACE_GETEVENTMSG -PTRACE_GETSIGINFO -PTRACE_KILL -PTRACE_O_EXITKILL -PTRACE_O_MASK -PTRACE_O_SUSPEND_SECCOMP -PTRACE_O_TRACECLONE -PTRACE_O_TRACEEXEC -PTRACE_O_TRACEEXIT -PTRACE_O_TRACEFORK -PTRACE_O_TRACESECCOMP -PTRACE_O_TRACESYSGOOD -PTRACE_O_TRACEVFORK -PTRACE_O_TRACEVFORKDONE -PTRACE_PEEKDATA -PTRACE_PEEKTEXT -PTRACE_PEEKUSER -PTRACE_POKEDATA -PTRACE_POKETEXT -PTRACE_POKEUSER -PTRACE_SECCOMP_GET_METADATA -PTRACE_SETOPTIONS -PTRACE_SETSIGINFO -PTRACE_SINGLESTEP -PTRACE_SYSCALL -PTRACE_TRACEME PT_DYNAMIC PT_GNU_EH_FRAME PT_GNU_RELRO @@ -3633,7 +3596,6 @@ pthread_spin_unlock pthread_spinlock_t pthread_t ptrace -ptrace_peeksiginfo_args ptrdiff_t ptsname ptsname_r @@ -3697,7 +3659,6 @@ sched_setparam sched_setscheduler sched_yield seccomp_data -seccomp_metadata seekdir select sem_close diff --git a/libc-test/semver/linux-gnu-x86_64.txt b/libc-test/semver/linux-gnu-x86_64.txt index 604f7d845e7b7..dfe109307fbd1 100644 --- a/libc-test/semver/linux-gnu-x86_64.txt +++ b/libc-test/semver/linux-gnu-x86_64.txt @@ -19,14 +19,12 @@ NFT_MSG_NEWOBJ PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -PTRACE_GET_RSEQ_CONFIGURATION PTRACE_SYSEMU PTRACE_SYSEMU_SINGLESTEP _libc_fpstate flock64 getcontext makecontext -ptrace_rseq_configuration setcontext swapcontext termios2 diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 83dd825584cd0..a02aad0931839 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -353,11 +353,6 @@ PROC_SUPER_MAGIC PR_SET_VMA PR_SET_VMA_ANON_NAME PTHREAD_MUTEX_ADAPTIVE_NP -PTRACE_GET_SYSCALL_INFO -PTRACE_SYSCALL_INFO_ENTRY -PTRACE_SYSCALL_INFO_EXIT -PTRACE_SYSCALL_INFO_NONE -PTRACE_SYSCALL_INFO_SECCOMP QNX4_SUPER_MAGIC QNX6_SUPER_MAGIC RDTGROUP_SUPER_MAGIC @@ -680,8 +675,6 @@ pthread_attr_setaffinity_np pthread_rwlockattr_getkind_np pthread_rwlockattr_getpshared pthread_rwlockattr_setkind_np -ptrace_peeksiginfo_args -ptrace_syscall_info putgrent putpwent pututxline diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index ced3f2b751508..48cdec2295795 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2267,6 +2267,8 @@ PTRACE_GETEVENTMSG PTRACE_GETREGSET PTRACE_GETSIGINFO PTRACE_GETSIGMASK +PTRACE_GET_RSEQ_CONFIGURATION +PTRACE_GET_SYSCALL_INFO PTRACE_INTERRUPT PTRACE_KILL PTRACE_LISTEN @@ -2288,6 +2290,8 @@ PTRACE_PEEKUSER PTRACE_POKEDATA PTRACE_POKETEXT PTRACE_POKEUSER +PTRACE_SECCOMP_GET_FILTER +PTRACE_SECCOMP_GET_METADATA PTRACE_SEIZE PTRACE_SETOPTIONS PTRACE_SETREGSET @@ -2295,6 +2299,10 @@ PTRACE_SETSIGINFO PTRACE_SETSIGMASK PTRACE_SINGLESTEP PTRACE_SYSCALL +PTRACE_SYSCALL_INFO_ENTRY +PTRACE_SYSCALL_INFO_EXIT +PTRACE_SYSCALL_INFO_NONE +PTRACE_SYSCALL_INFO_SECCOMP PTRACE_TRACEME PT_DYNAMIC PT_GNU_EH_FRAME @@ -3916,6 +3924,9 @@ pthread_spin_trylock pthread_spin_unlock pthread_spinlock_t ptrace +ptrace_peeksiginfo_args +ptrace_rseq_configuration +ptrace_syscall_info ptsname_r pwrite64 pwritev @@ -3956,6 +3967,7 @@ sched_setparam sched_setscheduler sctp_assoc_t seccomp_data +seccomp_metadata seccomp_notif seccomp_notif_addfd seccomp_notif_resp diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 61f91a183c4f7..4e2d52c623e45 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -356,17 +356,6 @@ s! { pub args: [::__u64; 6], } - pub struct seccomp_metadata { - pub filter_off: ::__u64, - pub flags: ::__u64, - } - - pub struct ptrace_peeksiginfo_args { - pub off: ::__u64, - pub flags: ::__u32, - pub nr: ::__s32, - } - // linux/input.h pub struct input_event { pub time: ::timeval, @@ -1613,31 +1602,6 @@ pub const EXTPROC: ::tcflag_t = 0o200000; pub const MAP_HUGETLB: ::c_int = 0x040000; -pub const PTRACE_TRACEME: ::c_int = 0; -pub const PTRACE_PEEKTEXT: ::c_int = 1; -pub const PTRACE_PEEKDATA: ::c_int = 2; -pub const PTRACE_PEEKUSER: ::c_int = 3; -pub const PTRACE_POKETEXT: ::c_int = 4; -pub const PTRACE_POKEDATA: ::c_int = 5; -pub const PTRACE_POKEUSER: ::c_int = 6; -pub const PTRACE_CONT: ::c_int = 7; -pub const PTRACE_KILL: ::c_int = 8; -pub const PTRACE_SINGLESTEP: ::c_int = 9; -pub const PTRACE_GETREGS: ::c_int = 12; -pub const PTRACE_SETREGS: ::c_int = 13; -pub const PTRACE_ATTACH: ::c_int = 16; -pub const PTRACE_DETACH: ::c_int = 17; -pub const PTRACE_SYSCALL: ::c_int = 24; -pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; -pub const PTRACE_GETREGSET: ::c_int = 0x4204; -pub const PTRACE_SETREGSET: ::c_int = 0x4205; -pub const PTRACE_SECCOMP_GET_METADATA: ::c_int = 0x420d; - -pub const PTRACE_EVENT_STOP: ::c_int = 128; - pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index c492f49f2995d..38d8f2f9d7f3c 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1250,37 +1250,6 @@ pub const CPU_SETSIZE: ::c_int = 128; pub const QFMT_VFS_V1: ::c_int = 4; -pub const PTRACE_TRACEME: ::c_int = 0; -pub const PTRACE_PEEKTEXT: ::c_int = 1; -pub const PTRACE_PEEKDATA: ::c_int = 2; -pub const PTRACE_PEEKUSER: ::c_int = 3; -pub const PTRACE_POKETEXT: ::c_int = 4; -pub const PTRACE_POKEDATA: ::c_int = 5; -pub const PTRACE_POKEUSER: ::c_int = 6; -pub const PTRACE_CONT: ::c_int = 7; -pub const PTRACE_KILL: ::c_int = 8; -pub const PTRACE_SINGLESTEP: ::c_int = 9; -pub const PTRACE_ATTACH: ::c_int = 16; -pub const PTRACE_DETACH: ::c_int = 17; -pub const PTRACE_SYSCALL: ::c_int = 24; -pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; -pub const PTRACE_GETREGSET: ::c_int = 0x4204; -pub const PTRACE_SETREGSET: ::c_int = 0x4205; -pub const PTRACE_SEIZE: ::c_int = 0x4206; -pub const PTRACE_INTERRUPT: ::c_int = 0x4207; -pub const PTRACE_LISTEN: ::c_int = 0x4208; -pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; - -pub const PTRACE_GETFPREGS: ::c_uint = 14; -pub const PTRACE_SETFPREGS: ::c_uint = 15; -pub const PTRACE_GETFPXREGS: ::c_uint = 18; -pub const PTRACE_SETFPXREGS: ::c_uint = 19; -pub const PTRACE_GETREGS: ::c_uint = 12; -pub const PTRACE_SETREGS: ::c_uint = 13; - pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 54c84fa617c86..c1a5aa35f33c2 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -176,8 +176,6 @@ cfg_if! { pub const SA_ONSTACK: ::c_int = 1; - pub const PTRACE_DETACH: ::c_uint = 11; - pub const F_SETLK: ::c_int = 8; pub const F_SETLKW: ::c_int = 9; @@ -222,8 +220,6 @@ cfg_if! { pub const SA_ONSTACK: ::c_int = 0x08000000; - pub const PTRACE_DETACH: ::c_uint = 17; - pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 96b5b532f74d2..8599ca936ee41 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -347,8 +347,6 @@ pub const POLLWRBAND: ::c_short = 0x200; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -pub const PTRACE_DETACH: ::c_uint = 17; - pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index eccbeff79f6c6..26dc7c8b9688f 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -766,7 +766,6 @@ pub const POLLWRBAND: ::c_short = 0x200; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; -pub const PTRACE_DETACH: ::c_uint = 17; pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index ac4d205c7f7a2..07168dae0bf1e 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -787,7 +787,6 @@ pub const TCSAFLUSH: ::c_int = 0x5410; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; -pub const PTRACE_DETACH: ::c_uint = 17; pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_GETREGS: ::c_uint = 12; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 3a06d26143a2b..93e04322ad03c 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -345,8 +345,6 @@ pub const POLLWRBAND: ::c_short = 0x200; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -pub const PTRACE_DETACH: ::c_uint = 17; - pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 750ee8f8436e8..3c93ee2668e91 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -360,7 +360,6 @@ pub const POLLWRNORM: ::c_short = 256; pub const POLLWRBAND: ::c_short = 512; pub const O_ASYNC: ::c_int = 8192; pub const O_NDELAY: ::c_int = 2048; -pub const PTRACE_DETACH: ::c_uint = 17; pub const EFD_NONBLOCK: ::c_int = 2048; pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 6bf730106e4c2..90c8ae1c5aaa2 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -472,8 +472,6 @@ pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const PTRACE_DETACH: ::c_uint = 17; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const MCL_ONFAULT: ::c_int = 0x0004; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 4ea00510f0aa1..50353bdc850e4 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -346,8 +346,6 @@ pub const POLLWRBAND: ::c_short = 0x100; pub const O_ASYNC: ::c_int = 0x40; pub const O_NDELAY: ::c_int = 0x4004; -pub const PTRACE_DETACH: ::c_uint = 17; - pub const EFD_NONBLOCK: ::c_int = 0x4000; pub const F_GETLK: ::c_int = 7; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 88d70d7deb5da..8e42a38b048d0 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -259,14 +259,6 @@ s! { __unused4: u64, __unused5: u64 } - - pub struct ptrace_rseq_configuration { - pub rseq_abi_pointer: ::__u64, - pub rseq_abi_size: ::__u32, - pub signature: ::__u32, - pub flags: ::__u32, - pub pad: ::__u32, - } } s_no_extra_traits! { @@ -536,9 +528,6 @@ pub const POLLWRBAND: ::c_short = 0x200; pub const O_ASYNC: ::c_int = 0x2000; pub const O_NDELAY: ::c_int = 0x800; -pub const PTRACE_DETACH: ::c_uint = 17; -pub const PTRACE_GET_RSEQ_CONFIGURATION: ::c_uint = 0x420f; - pub const EFD_NONBLOCK: ::c_int = 0x800; pub const F_GETLK: ::c_int = 5; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index f68efbe85bbf5..317c8abbd2f7f 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -325,37 +325,6 @@ s! { pub semaem: ::c_int, } - pub struct ptrace_peeksiginfo_args { - pub off: ::__u64, - pub flags: ::__u32, - pub nr: ::__s32, - } - - pub struct __c_anonymous_ptrace_syscall_info_entry { - pub nr: ::__u64, - pub args: [::__u64; 6], - } - - pub struct __c_anonymous_ptrace_syscall_info_exit { - pub sval: ::__s64, - pub is_error: ::__u8, - } - - pub struct __c_anonymous_ptrace_syscall_info_seccomp { - pub nr: ::__u64, - pub args: [::__u64; 6], - pub ret_data: ::__u32, - } - - pub struct ptrace_syscall_info { - pub op: ::__u8, - pub pad: [::__u8; 3], - pub arch: ::__u32, - pub instruction_pointer: ::__u64, - pub stack_pointer: ::__u64, - pub u: __c_anonymous_ptrace_syscall_info_data, - } - // linux/if_xdp.h pub struct sockaddr_xdp { @@ -588,18 +557,6 @@ impl siginfo_t { } } -pub union __c_anonymous_ptrace_syscall_info_data { - pub entry: __c_anonymous_ptrace_syscall_info_entry, - pub exit: __c_anonymous_ptrace_syscall_info_exit, - pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, -} -impl ::Copy for __c_anonymous_ptrace_syscall_info_data {} -impl ::Clone for __c_anonymous_ptrace_syscall_info_data { - fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { - *self - } -} - s_no_extra_traits! { pub struct utmpx { pub ut_type: ::c_short, @@ -699,40 +656,6 @@ cfg_if! { self.__glibc_reserved.hash(state); } } - - impl PartialEq for __c_anonymous_ptrace_syscall_info_data { - fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { - unsafe { - self.entry == other.entry || - self.exit == other.exit || - self.seccomp == other.seccomp - } - } - } - - impl Eq for __c_anonymous_ptrace_syscall_info_data {} - - impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_ptrace_syscall_info_data") - .field("entry", &self.entry) - .field("exit", &self.exit) - .field("seccomp", &self.seccomp) - .finish() - } - } - } - - impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { - fn hash(&self, state: &mut H) { - unsafe { - self.entry.hash(state); - self.exit.hash(state); - self.seccomp.hash(state); - } - } - } } } @@ -973,36 +896,6 @@ cfg_if! { pub const CPU_SETSIZE: ::c_int = 0x400; -pub const PTRACE_TRACEME: ::c_uint = 0; -pub const PTRACE_PEEKTEXT: ::c_uint = 1; -pub const PTRACE_PEEKDATA: ::c_uint = 2; -pub const PTRACE_PEEKUSER: ::c_uint = 3; -pub const PTRACE_POKETEXT: ::c_uint = 4; -pub const PTRACE_POKEDATA: ::c_uint = 5; -pub const PTRACE_POKEUSER: ::c_uint = 6; -pub const PTRACE_CONT: ::c_uint = 7; -pub const PTRACE_KILL: ::c_uint = 8; -pub const PTRACE_SINGLESTEP: ::c_uint = 9; -pub const PTRACE_ATTACH: ::c_uint = 16; -pub const PTRACE_SYSCALL: ::c_uint = 24; -pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; -pub const PTRACE_GETREGSET: ::c_uint = 0x4204; -pub const PTRACE_SETREGSET: ::c_uint = 0x4205; -pub const PTRACE_SEIZE: ::c_uint = 0x4206; -pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; -pub const PTRACE_LISTEN: ::c_uint = 0x4208; -pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; -pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a; -pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b; -pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e; -pub const PTRACE_SYSCALL_INFO_NONE: ::__u8 = 0; -pub const PTRACE_SYSCALL_INFO_ENTRY: ::__u8 = 1; -pub const PTRACE_SYSCALL_INFO_EXIT: ::__u8 = 2; -pub const PTRACE_SYSCALL_INFO_SECCOMP: ::__u8 = 3; - // linux/fs.h // Flags for preadv2/pwritev2 diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 9401949b4f124..3dd1ba1584fdf 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2624,7 +2624,6 @@ cfg_if! { pub const IPV6_MULTICAST_ALL: ::c_int = 29; pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; pub const PACKET_MR_UNICAST: ::c_int = 3; - pub const PTRACE_EVENT_STOP: ::c_int = 128; pub const UDP_SEGMENT: ::c_int = 103; pub const UDP_GRO: ::c_int = 104; } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index bfdbb0f0bad59..9f471fee2d757 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -714,38 +714,6 @@ pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; pub const CPU_SETSIZE: ::c_int = 128; -pub const PTRACE_TRACEME: ::c_int = 0; -pub const PTRACE_PEEKTEXT: ::c_int = 1; -pub const PTRACE_PEEKDATA: ::c_int = 2; -pub const PTRACE_PEEKUSER: ::c_int = 3; -pub const PTRACE_POKETEXT: ::c_int = 4; -pub const PTRACE_POKEDATA: ::c_int = 5; -pub const PTRACE_POKEUSER: ::c_int = 6; -pub const PTRACE_CONT: ::c_int = 7; -pub const PTRACE_KILL: ::c_int = 8; -pub const PTRACE_SINGLESTEP: ::c_int = 9; -pub const PTRACE_GETREGS: ::c_int = 12; -pub const PTRACE_SETREGS: ::c_int = 13; -pub const PTRACE_GETFPREGS: ::c_int = 14; -pub const PTRACE_SETFPREGS: ::c_int = 15; -pub const PTRACE_ATTACH: ::c_int = 16; -pub const PTRACE_DETACH: ::c_int = 17; -pub const PTRACE_GETFPXREGS: ::c_int = 18; -pub const PTRACE_SETFPXREGS: ::c_int = 19; -pub const PTRACE_SYSCALL: ::c_int = 24; -pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; -pub const PTRACE_GETREGSET: ::c_int = 0x4204; -pub const PTRACE_SETREGSET: ::c_int = 0x4205; -pub const PTRACE_SEIZE: ::c_int = 0x4206; -pub const PTRACE_INTERRUPT: ::c_int = 0x4207; -pub const PTRACE_LISTEN: ::c_int = 0x4208; -pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; -pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a; -pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b; - pub const RWF_HIPRI: ::c_int = 0x00000001; pub const RWF_DSYNC: ::c_int = 0x00000002; pub const RWF_SYNC: ::c_int = 0x00000004; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 32c65545a8905..ac5d295c83cb2 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -73,12 +73,6 @@ s! { pub e_termination: ::c_short, pub e_exit: ::c_short, } - - pub struct ptrace_peeksiginfo_args { - pub off: ::__u64, - pub flags: ::__u32, - pub nr: ::__s32, - } } impl siginfo_t { @@ -179,35 +173,6 @@ pub const AF_VSOCK: ::c_int = 40; pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70; pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342; -pub const PTRACE_TRACEME: ::c_int = 0; -pub const PTRACE_PEEKTEXT: ::c_int = 1; -pub const PTRACE_PEEKDATA: ::c_int = 2; -pub const PTRACE_PEEKUSER: ::c_int = 3; -pub const PTRACE_POKETEXT: ::c_int = 4; -pub const PTRACE_POKEDATA: ::c_int = 5; -pub const PTRACE_POKEUSER: ::c_int = 6; -pub const PTRACE_CONT: ::c_int = 7; -pub const PTRACE_KILL: ::c_int = 8; -pub const PTRACE_SINGLESTEP: ::c_int = 9; -pub const PTRACE_GETREGS: ::c_int = 12; -pub const PTRACE_SETREGS: ::c_int = 13; -pub const PTRACE_GETFPREGS: ::c_int = 14; -pub const PTRACE_SETFPREGS: ::c_int = 15; -pub const PTRACE_ATTACH: ::c_int = 16; -pub const PTRACE_DETACH: ::c_int = 17; -pub const PTRACE_GETFPXREGS: ::c_int = 18; -pub const PTRACE_SETFPXREGS: ::c_int = 19; -pub const PTRACE_SYSCALL: ::c_int = 24; -pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; -pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; -pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; -pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; -pub const PTRACE_GETREGSET: ::c_int = 0x4204; -pub const PTRACE_SETREGSET: ::c_int = 0x4205; -pub const PTRACE_SEIZE: ::c_int = 0x4206; -pub const PTRACE_INTERRUPT: ::c_int = 0x4207; -pub const PTRACE_LISTEN: ::c_int = 0x4208; - pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; @@ -337,10 +302,6 @@ pub const PACKET_MR_UNICAST: ::c_int = 3; pub const PF_NFC: ::c_int = 39; pub const PF_VSOCK: ::c_int = 40; pub const POSIX_MADV_DONTNEED: ::c_int = 4; -pub const PTRACE_EVENT_STOP: ::c_int = 128; -pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a; -pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; -pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b; pub const RTLD_NOLOAD: ::c_int = 0x00004; pub const RUSAGE_THREAD: ::c_int = 1; pub const SHM_EXEC: ::c_int = 0o100000; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index de27746971ed3..4cb846aadf93d 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -204,6 +204,50 @@ s! { pub msg_hdr: ::msghdr, pub msg_len: ::c_uint, } + + pub struct seccomp_metadata { + pub filter_off: u64, + pub flags: u64, + } + + pub struct ptrace_peeksiginfo_args { + pub off: u64, + pub flags: u32, + pub nr: i32, + } + + pub struct ptrace_rseq_configuration { + pub rseq_abi_pointer: u64, + pub rseq_abi_size: u32, + pub signature: u32, + pub flags: u32, + pub pad: u32, + } + + pub struct __c_anonymous_ptrace_syscall_info_entry { + pub nr: u64, + pub args: [u64; 6], + } + + pub struct __c_anonymous_ptrace_syscall_info_exit { + pub sval: i64, + pub is_error: u8, + } + + pub struct __c_anonymous_ptrace_syscall_info_seccomp { + pub nr: u64, + pub args: [u64; 6], + pub ret_data: u32, + } + + pub struct ptrace_syscall_info { + pub op: u8, + pub pad: [u8; 3], + pub arch: u32, + pub instruction_pointer: u64, + pub stack_pointer: u64, + pub u: __c_anonymous_ptrace_syscall_info_data, + } } s_no_extra_traits! { @@ -257,6 +301,18 @@ s_no_extra_traits! { } } +pub union __c_anonymous_ptrace_syscall_info_data { + pub entry: __c_anonymous_ptrace_syscall_info_entry, + pub exit: __c_anonymous_ptrace_syscall_info_exit, + pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, +} +impl ::Copy for __c_anonymous_ptrace_syscall_info_data {} +impl ::Clone for __c_anonymous_ptrace_syscall_info_data { + fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { + *self + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for epoll_event { @@ -430,6 +486,40 @@ cfg_if! { self.sigev_notify_thread_id.hash(state); } } + + impl PartialEq for __c_anonymous_ptrace_syscall_info_data { + fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { + unsafe { + self.entry == other.entry || + self.exit == other.exit || + self.seccomp == other.seccomp + } + } + } + + impl Eq for __c_anonymous_ptrace_syscall_info_data {} + + impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_ptrace_syscall_info_data") + .field("entry", &self.entry) + .field("exit", &self.exit) + .field("seccomp", &self.seccomp) + .finish() + } + } + } + + impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { + fn hash(&self, state: &mut H) { + unsafe { + self.entry.hash(state); + self.exit.hash(state); + self.seccomp.hash(state); + } + } + } } } @@ -1194,6 +1284,40 @@ pub const WHOLE_SECONDS: ::c_int = 0x2000000; pub const STICKY_TIMEOUTS: ::c_int = 0x4000000; pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000; +pub const PTRACE_TRACEME: ::c_uint = 0; +pub const PTRACE_PEEKTEXT: ::c_uint = 1; +pub const PTRACE_PEEKDATA: ::c_uint = 2; +pub const PTRACE_PEEKUSER: ::c_uint = 3; +pub const PTRACE_POKETEXT: ::c_uint = 4; +pub const PTRACE_POKEDATA: ::c_uint = 5; +pub const PTRACE_POKEUSER: ::c_uint = 6; +pub const PTRACE_CONT: ::c_uint = 7; +pub const PTRACE_KILL: ::c_uint = 8; +pub const PTRACE_SINGLESTEP: ::c_uint = 9; +pub const PTRACE_ATTACH: ::c_uint = 16; +pub const PTRACE_DETACH: ::c_uint = 17; +pub const PTRACE_SYSCALL: ::c_uint = 24; +pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200; +pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201; +pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202; +pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203; +pub const PTRACE_GETREGSET: ::c_uint = 0x4204; +pub const PTRACE_SETREGSET: ::c_uint = 0x4205; +pub const PTRACE_SEIZE: ::c_uint = 0x4206; +pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; +pub const PTRACE_LISTEN: ::c_uint = 0x4208; +pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; +pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a; +pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b; +pub const PTRACE_SECCOMP_GET_FILTER: ::c_int = 0x420c; +pub const PTRACE_SECCOMP_GET_METADATA: ::c_int = 0x420d; +pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e; +pub const PTRACE_GET_RSEQ_CONFIGURATION: ::c_uint = 0x420f; +pub const PTRACE_SYSCALL_INFO_NONE: u8 = 0; +pub const PTRACE_SYSCALL_INFO_ENTRY: u8 = 1; +pub const PTRACE_SYSCALL_INFO_EXIT: u8 = 2; +pub const PTRACE_SYSCALL_INFO_SECCOMP: u8 = 3; + // Options set using PTRACE_SETOPTIONS. pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; pub const PTRACE_O_TRACEFORK: ::c_int = 0x00000002; @@ -1215,6 +1339,7 @@ pub const PTRACE_EVENT_EXEC: ::c_int = 4; pub const PTRACE_EVENT_VFORK_DONE: ::c_int = 5; pub const PTRACE_EVENT_EXIT: ::c_int = 6; pub const PTRACE_EVENT_SECCOMP: ::c_int = 7; +pub const PTRACE_EVENT_STOP: ::c_int = 128; pub const __WNOTHREAD: ::c_int = 0x20000000; pub const __WALL: ::c_int = 0x40000000;