-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
UdpSocket receive to short buffer behaves differently on Unix and Windows #55794
Comments
mio emulates the standard library and so tokio inherits this behaviour too. So if I'm not an outlier in finding this behaviour unusual it's likely that this error is mishandled in a lot of code. To test that supposition I thought I'd do a quick survey of servers. I didn't find many that I could easily run but here are the results:
|
Cc @Ralith as well. |
Is the current Unix behavior the right default? If quinn were to ever receive into a shorter buffer (which is possible, since maximum packet size is negotiated by QUIC and memory isn't always cheap), we might prefer to detect and discard truncated packets, since they would be deemed malformed soon after anyway. Note that the windows behavior should be implementable on POSIX-compatible systems by using Note that returning an error doesn't render read data unusable, because by definition, if the message was truncated the entire supplied buffer was filled. |
Do you happen to have a backtrace for this? |
I hadn't really thought about that. Are there any other errors that could require special handling other than perhaps |
The other weird Linux UDP behaviors I'm aware of are:
|
Closing due to inactivity. |
Isn’t this worth keeping open? It seems like a pretty wide open exploit potential on Windows. |
It seems like a decision still needs to be made for which behavior to favor, if any. I made an argument for the Windows default to be adopted above. |
3 months seems hardly like enough time to close for inactivity, and there's definitely some unresolved concerns here. I'm definitely in favor of returning an error when the input buffer was too small for the incoming packet. Silently truncating is not the right approach to making a robust standard library. |
I didn't mean to imply what the solution should be, only that currently, it looks like many of us have some issues to resolve, that the stdlib should most likely help compensate for. |
Right, I'm just agreeing that there's an unsolved problem here. |
I just noticed that the example for UdpSocket suggests an error won't be returned:
(I'm only mentioning this as it may need to be amended.) |
What's the status of the issue? I prefer emitting an error in this case like the default behavior on windows. Maybe we can add a new variant to |
Nobody's cared enough to work on it, I think. |
I thought this was waiting on a decision from the libs team. What is the process here? |
The correct process is to poke @rust-lang/libs and ask them to make a decision on this. |
AFAICS, a-priori one does not know if hte size of the incoming datagram will exceed the user's message buffer. So, on Unix it may be truncated, and on Windows we may get an error. AFAICS, the appication needs to deal with both cases. |
On Windows it is truncated and you get an error telling you it was truncated. On Unix it is truncated without any indication that it was truncated. |
On Unix receiving to a buffer shorter than the incoming payload silently truncates the read. On Windows the read is completed but an error is returned. Not being that familiar with Windows I found this behaviour surprising.
The following comment in
sys/windows/net.rs
suggests that making Unix and Windows behave the same is (at times) a goal of the standard library:If it is I'd like to propose that
WSAEMSGSIZE
be absorbed so that both platforms behave the same.The text was updated successfully, but these errors were encountered: