Skip to content

Commit b931d13

Browse files
committed
Fix syscall_info
According to the man page: > The addr argument contains the size of the buffer pointed to by the > data argument (i.e., sizeof(struct ptrace_syscall_info)). We were setting the data argument, so this syscall was returning garbage. This is easily reproduced and verified by looking at the `op` value, which should range from 0 to 3. The PR associated with this commit contains a sample program to demonstrate this. The fix is done in the `ptrace_get_data` helper to avoid duplicating its implementation just for `syscall_info`. Of all the other callers, all but one are documented as ignoring `addr`. The other one (`PTRACE_GETREGS`) is documented as ignoring `addr` _except on SPARC systems_, on which `addr` and `data` are reversed. However, this is already not respected by `nix`, so this changes is not disruptive in this regard. There should be no performance concerns as we are replacing one constant with another.
1 parent a72936d commit b931d13

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sys/ptrace/linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ fn ptrace_get_data<T>(request: Request, pid: Pid) -> Result<T> {
504504
libc::ptrace(
505505
request as RequestType,
506506
libc::pid_t::from(pid),
507-
ptr::null_mut::<T>(),
507+
size_of::<T>(),
508508
data.as_mut_ptr(),
509509
)
510510
};

0 commit comments

Comments
 (0)