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

sock_ctrl_msg: mark recv_with_fds as unsafe #135

Merged
merged 1 commit into from
Aug 19, 2021

Conversation

alyssais
Copy link
Contributor

@alyssais alyssais commented Aug 12, 2021

Writes to arbitrary pointers are unsafe in Rust. It's the caller's job to ensure that it's safe for the memory they are writing to can contain whatever arbitrary bytes are received over the socket. For example, it would be unsafe to have an iovec pointing to the return value of str::as_mut_ptr, because strings can only contain byte sequences that are valid UTF-8.

Because it's on the caller to make sure they're passing pointers safely, any function that writes to iovecs has to be marked as unsafe.

Signed-off-by: Alyssa Ross hi@alyssa.is


Corresponding vhost change: rust-vmm/vhost#69

jiangliu
jiangliu previously approved these changes Aug 12, 2021
jiangliu
jiangliu previously approved these changes Aug 13, 2021
@alyssais
Copy link
Contributor Author

Do I need to add tests to get the coverage up like the CI says, even though line count has just increased because of reformatting?

@jiangliu
Copy link
Member

jiangliu commented Aug 13, 2021

Only meaningful test cases are really needed, and for this case we could decrease the coverage:)
But really welcome for useful test cases!

Writes to arbitrary pointers are unsafe in Rust.  It's the caller's
job to ensure that it's safe for the memory they are writing to can
contain whatever arbitrary bytes are received over the socket.  For
example, it would be unsafe to have an iovec pointing to the return
value of str::as_mut_ptr, because strings can only contain byte
sequences that are valid UTF-8.

Because it's on the caller to make sure they're passing pointers
safely, any function that writes to iovecs has to be marked as unsafe.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
@alyssais
Copy link
Contributor Author

I've rebased this in the hope that e39373f will fix the coverage issue.

@alyssais alyssais requested a review from jiangliu August 13, 2021 16:43
@lauralt lauralt merged commit 0960099 into rust-vmm:master Aug 19, 2021
slp added a commit to slp/vhost-user-backend that referenced this pull request Sep 23, 2021
In addition to bringing the features from the new vhost crate, this
fixes the breakage caused by rust-vmm/vmm-sys-util#135

Signed-off-by: Sergio Lopez <slp@redhat.com>
jiangliu pushed a commit to rust-vmm/vhost-user-backend that referenced this pull request Sep 23, 2021
In addition to bringing the features from the new vhost crate, this
fixes the breakage caused by rust-vmm/vmm-sys-util#135

Signed-off-by: Sergio Lopez <slp@redhat.com>
@alyssais alyssais deleted the sock_ctrl_msg branch August 3, 2022 13:10
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 this pull request may close these issues.

None yet

3 participants