Skip to content

linux add ptrace_syscall_info ptrace query. #2606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3325,7 +3325,9 @@ fn test_linux(target: &str) {
// FIXME: It now takes mode_t since glibc 2.31 on some targets.
(struct_ == "ipc_perm" && field == "mode"
&& ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32)
)
) ||
// the `u` field is in fact an anonymous union
(gnu && struct_ == "ptrace_syscall_info" && (field == "u" || field == "pad"))
});

cfg.skip_roundtrip(move |s| match s {
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ PF_MPLS
PF_XDP
PROC_SUPER_MAGIC
PTHREAD_MUTEX_ADAPTIVE_NP
PTRACE_GET_SYSCALL_INFO
QNX4_SUPER_MAGIC
QNX6_SUPER_MAGIC
RDTGROUP_SUPER_MAGIC
Expand Down Expand Up @@ -617,6 +618,7 @@ pthread_rwlockattr_getpshared
pthread_rwlockattr_setkind_np
pthread_setname_np
ptrace_peeksiginfo_args
ptrace_syscall_info
pututxline
pwritev2
pwritev64
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub type msgqnum_t = ::c_ulong;
pub type msglen_t = ::c_ulong;
pub type nlink_t = u32;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;
pub type __fsword_t = i32;
pub type fsblkcnt64_t = u64;
pub type fsfilcnt64_t = u64;
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub type nlink_t = u32;
pub type blksize_t = i32;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;

s! {
pub struct sigaction {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/mips64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub type nlink_t = u64;
pub type suseconds_t = i64;
pub type wchar_t = i32;
pub type __u64 = ::c_ulong;
pub type __s64 = ::c_long;

s! {
pub struct stat {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub type nlink_t = u64;
pub type blksize_t = i64;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulong;
pub type __s64 = ::c_long;

s! {
pub struct sigaction {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub type fsblkcnt64_t = ::c_ulong;
pub type fsfilcnt64_t = ::c_ulong;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;

s! {
pub struct pthread_attr_t {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub type suseconds_t = i64;
pub type wchar_t = i32;
pub type greg_t = u64;
pub type __u64 = u64;
pub type __s64 = i64;

s! {
pub struct sigaction {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub type nlink_t = u32;
pub type blksize_t = i64;
pub type suseconds_t = i32;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;

s! {
pub struct sigaction {
Expand Down
1 change: 1 addition & 0 deletions src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub type blksize_t = i64;
pub type greg_t = i64;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;

s! {
pub struct sigaction {
Expand Down
77 changes: 77 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,32 @@ s! {
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,
#[cfg(libc_union)]
pub u: __c_anonymous_ptrace_syscall_info_data,
}
}

impl siginfo_t {
Expand Down Expand Up @@ -411,6 +437,18 @@ cfg_if! {
self.sifields().sigchld.si_stime
}
}

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
}
}
}
}

Expand Down Expand Up @@ -509,6 +547,44 @@ cfg_if! {
self.__glibc_reserved.hash(state);
}
}

#[cfg(libc_union)]
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
}
}
}

#[cfg(libc_union)]
impl Eq for __c_anonymous_ptrace_syscall_info_data {}

#[cfg(libc_union)]
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()
}
}
}

#[cfg(libc_union)]
impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
self.entry.hash(state);
self.exit.hash(state);
self.seccomp.hash(state);
}
}
}
}
}

Expand Down Expand Up @@ -906,6 +982,7 @@ 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_GET_SYSCALL_INFO: ::c_uint = 0x420e;

// linux/fs.h

Expand Down