-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
unix: Non-mutable bufs in send_vectored_with_ancillary_to #79753
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @withoutboats (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
How do you know this is true? Isn't it up to the implementation? |
ba0f877
to
073f32a
Compare
073f32a
to
8920d15
Compare
I don't know how to directly prove that sendmsg does not change the buffers. But generally, syscalls don't modify buffers unless it is written explicitly. write_vectored has a similar problem. It receives non-mutable IoSlices and casts them to |
Oh I see - the syscall accepts a const pointer, but the struct itself contains a mutable pointer, which is part of the type definition, not the function signature. Hmm, that makes sense - C doesn't have tools for saying "this pointer is only mut when the struct is". I'm not 100% comfortable with changing the cast (since it's better to err on the side of caution when dealing with UB) but I won't block it if someone else approves. |
If we can't figure out the semantics of For example, the fd-queue crate can be ported to Additionally, if the kernel was allowed to overwrite the buffer with arbitrary data, could |
@lukaslihotzki any updates? |
I have asked a question on Stack Overflow. |
Ping from triage @rustbot label: -S-waiting-on-review +S-waiting-on-author |
@lukaslihotzki Closing this due to inactivity. If you find a way how to resolve this, feel free to open a new pull request and we can move it forward from there. Thanks for taking the time to contribute. |
unix: Non-mutable bufs in send_vectored_with_ancillary_to This is the same PR as [rust-lang#79753](rust-lang#79753). It was closed because of inactivity. Therefore, I create a new one. ``@lukaslihotzki``
unix: Non-mutable bufs in send_vectored_with_ancillary_to This is the same PR as [rust-lang#79753](rust-lang#79753). It was closed because of inactivity. Therefore, I create a new one. ```@lukaslihotzki```
unix: Non-mutable bufs in send_vectored_with_ancillary_to This is the same PR as [rust-lang#79753](rust-lang#79753). It was closed because of inactivity. Therefore, I create a new one. ````@lukaslihotzki````
send_vectored_with_ancillary_to
usesstruct msghdr
internally, which contains a*mut iovec
. That's why this function currently takes a mutable reference tobufs
. However, these buffers aren't actually modified on sendmsg, so let this function take a non-mutable reference instead and cast the rawiovec
pointer to mutable as an implementation detail.