Skip to content

Commit 0133f80

Browse files
committed
Add PTRACE_SET_SYSCALL_INFO and set_syscall_info wrapper
1 parent d510fb4 commit 0133f80

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

2739.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added set_syscall_info to ptrace on linux

2739.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bumped libc from 0.2.180 to 0.2.181

src/sys/ptrace/linux.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ libc_enum! {
148148
PTRACE_SYSEMU_SINGLESTEP,
149149
#[cfg(all(target_os = "linux", target_env = "gnu"))]
150150
PTRACE_GET_SYSCALL_INFO,
151+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
152+
PTRACE_SET_SYSCALL_INFO,
151153
}
152154
}
153155

@@ -576,6 +578,21 @@ pub fn syscall_info(pid: Pid) -> Result<libc::ptrace_syscall_info> {
576578
ptrace_get_data::<libc::ptrace_syscall_info>(Request::PTRACE_GET_SYSCALL_INFO, pid)
577579
}
578580

581+
/// Set the information of the syscall that caused the stop, as with
582+
/// `ptrace(PTRACE_SET_SYSCALL_INFO, ...`.
583+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
584+
pub fn set_syscall_info(pid: Pid, syscall_info: &libc::ptrace_syscall_info) -> Result<()> {
585+
let res = unsafe {
586+
libc::ptrace(
587+
Request::PTRACE_SET_SYSCALL_INFO as RequestType,
588+
libc::pid_t::from(pid),
589+
mem::size_of::<libc::ptrace_syscall_info>(),
590+
syscall_info as *const _ as *const c_void,
591+
)
592+
};
593+
Errno::result(res).map(drop)
594+
}
595+
579596
/// Sets the process as traceable, as with `ptrace(PTRACE_TRACEME, ...)`
580597
///
581598
/// Indicates that this process is to be traced by its parent.

0 commit comments

Comments
 (0)