nix
nix copied to clipboard
Change the type of data of ptrace::write to make it safe
What does this PR do
Fix #2323
Change the signature of ptrace::write and ptrace::write_user to make them safe
Checklist:
- [x] I have read
CONTRIBUTING.md - [x] I have written necessary tests and rustdoc comments
- [x] A change log has been added if this PR modifies nix's API
I use the same command, but could not reproduce the issue, does anyone know the reason?
I ran cargo clippy --target x86_64-unknown-linux-gnu --all-targets --all-features -- -D warnings -A unknown-lints
Well, it is indeed weird, I didn't reproduce it either...
Will investigate more.
I kinda think this error is a false positive?
My guess on the reason why it is triggered is that we are directly casting a c_long to a raw pointer, but I think this is fine as the kernel won't treat it as a raw pointer but an unsigned long, so we can:
-
Allow it
#[allow(clippy::not_unsafe_ptr_arg_deref)] -
Write a comment stating why the usages of
ptrace_other()withinwrite()andwrite_user()are safe// Safety:
Thanks for the suggestions, it's past now!