-
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
recvmmsg
may cause UB
#2119
Comments
As a side note, I'm not convinced that Even worse, In the context of |
More than anything else, the recvmsg family of functions makes me want to quit my programming job and start a career cleaning toilets. That's why I've procrastinated on this issue for so long. But I've spent some time today reviewing all this stuff, and I think that you're right. I think there are a bunch of other issues with our sendmsg/recvmsg APIs too, but we can fix them separately. |
Description
recvmmsg
currently mutates state through shared references, which is immediately UB. This is caused by using shared references in the function signature, where mutable references are requried.Detailed Explanation
Currently,
recvmmsg
essentially does the following:This boils down to: (stripping one layer of slices)
Although we have a mutable reference to the inner slice, it is hidden behind a shared reference, which behaves exactly like it was borrowed immutably in first place. Casting a shared reference to a
*mut _
pointer and mutating the value through that pointer is always UB.Example demonstrating this bug
Proposal
Change the function signature of
recvmmsg
to:or (preferably, but inconsistent with
sendmmsg
)The text was updated successfully, but these errors were encountered: