diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs index 88b056d07f..ac18544033 100644 --- a/src/sys/ptrace.rs +++ b/src/sys/ptrace.rs @@ -70,9 +70,12 @@ mod ffi { } } -/// Performs a ptrace request. If the request in question is provided by a specialised function +/// A low-level wrapper for `ptrace`. If available, the higher-level wrappers should be considered instead. +/// Performs a `ptrace` request. If the request in question is provided by a specialised function /// this function will return an unsupported operation error. -pub fn ptrace(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result { +/// +/// When used incorrectly, this function may crash the tracer or the tracee, thus is marked `unsafe`. +unsafe pub fn ptrace(request: ptrace::PtraceRequest, pid: Pid, addr: *mut c_void, data: *mut c_void) -> Result { use self::ptrace::*; match request { @@ -202,12 +205,19 @@ pub fn traceme() -> Result<()> { } /// Makes the `PTRACE_PEEKDATA` request to ptrace -pub fn peekdata(pid: Pid, addr: c_long) -> Result { +/// +/// This function allows to access arbitrary data in the traced process +/// and may crash the inferior if used incorrectly and is thus marked `unsafe`. +unsafe pub fn peekdata(pid: Pid, addr: c_long) -> Result { ptrace(ptrace::PTRACE_PEEKDATA, pid, addr as *mut c_void, ptr::null_mut()) } /// Makes the `PTRACE_PEEKDATA` request to ptrace -pub fn pokedata(pid: Pid, addr: c_long, val: c_long) -> Result<()> { +/// +/// This function allows to access arbitrary data in the traced process +/// and may crash the inferior or introduce race conditions if used +/// incorrectly and is thus marked `unsafe`. +unsafe pub fn pokedata(pid: Pid, addr: c_long, val: c_long) -> Result<()> { ptrace( ptrace::PTRACE_POKEDATA, pid,