-
Notifications
You must be signed in to change notification settings - Fork 666
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
Fix Clippy warnings on FreeBSD with the latest nightly #1639
Conversation
asomers
commented
Jan 22, 2022
- Better type safety for mqueue
- Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSD
On some platforms, mqd_t is a pointer. That means code like the below can trigger a segfault. Fix it by defining a Newtype around mqd_t that prevents use-after-free and dangling pointer scenarios. ```rust fn invalid_mqd_t() { let mqd: libc::mqd_t = std::ptr::null_mut(); mq_close(mqd).unwrap(); } ``` Also, get test coverage for mqueue in CI on FreeBSD.
Technically these functions don't violate Rust's safety rules, because libc::ptrace doesn't dereference those pointer args. Instead, it passes them directly to the kernel.
Supersedes #1638 |
bors r+ |
POSIX does explicitly mention that |
@lucab could you give an example in Rust, C, or pseudocode? How would that feature work? |
Sure, and thanks for the prompt reply! |
I think it's worth noting that the conversion itself was infallible. You could end up with an invalid mqueue-descriptor, as
Implementing We should probably implement all four traits on Linux and any other platforms that use FDs instead of pointers for |