Skip to content
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

Change the signature of ptrace::write to make it safe #2323

Closed
ShuiRuTian opened this issue Feb 27, 2024 · 1 comment · Fixed by #2324
Closed

Change the signature of ptrace::write to make it safe #2323

ShuiRuTian opened this issue Feb 27, 2024 · 1 comment · Fixed by #2324

Comments

@ShuiRuTian
Copy link
Contributor

ShuiRuTian commented Feb 27, 2024

For now, the whole impl of write is

pub unsafe fn write(
    pid: Pid,
    addr: AddressType,
    data: *mut c_void,
) -> Result<()> {
    unsafe { ptrace_other(Request::PTRACE_POKEDATA, pid, addr, data).map(drop) }
}

In ptrace(2), it's mentioned data is "a word", which should be the same as the return type of read(c_long, in current code).

So, why don't we change the type of data to c_long, and make it safe?

Or maybe the type could be a byte array like [u8; sizeof::<c_long>()]

@SteveLauC
Copy link
Member

It was made unsafe indeed for this argument, see #1245, so I think this would be a reasonable change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants