Closed eseft closed 1 month ago
Also, there is something about ptrace_peek
request type I found in man page. It's expecting fourth parameter to be something like ^uint
to fill data from specified address
C library/kernel differences
At the system call level, the PTRACE_PEEKTEXT, PTRACE_PEEKDATA,
and PTRACE_PEEKUSER operations have a different API: they store
the result at the address specified by the data parameter, and
the return value is the error flag. The glibc wrapper function
provides the API given in DESCRIPTION above, with the result
being returned via the function return value.
Not sure how this went over my mind, turns out the signal was passed in the addr
parameter, and the data
parameter was ignored. According to the documentation data
contains the signal and addr
is ignored.
I'll submit a PR that fixes this issue shortly.
If the signal is not a valid signal number, the function would return EIO (https://elixir.bootlin.com/linux/v6.11/source/kernel/ptrace.c#L827), so I guess you really had to be lucky for some uninitialized data to have been a valid signal number haha
Context
It looks like the
ptrace
syscall with request typesptrace_cont
,ptrace_singlestep
,ptrace_syscall
,ptrace_sysemu
andptrace_sysemu_singlestep
expecting to getSignal
as a 4th parameter according toptrace
man page.Expected Behavior
When tracer waits for tracee to stop and do
ptrace(linux.PTRACE_CONT,...)
no errors should occur.Current Behavior
Whenever
ptrace(linux.PTRACE_CONT,...)
called it returnsEIO
error.Failure Information (for bugs)
Steps to Reproduce
import "core:fmt" import "core:os" import "core:sys/linux"
main :: proc() { pid, err := linux.fork() assert(err == nil)
}
ptrace_cont: EIO ....
ptrace(PTRACE_CONT, 13337, NULL, 459103680) = -1 EIO (Input/output error)