Skip to content

Big-endian fix: ApplyMask in System.Net.WebSockets.ManagedWebSocket #55422

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

Merged
merged 1 commit into from
Jul 10, 2021
Merged

Big-endian fix: ApplyMask in System.Net.WebSockets.ManagedWebSocket #55422

merged 1 commit into from
Jul 10, 2021

Conversation

uweigand
Copy link
Contributor

@uweigand uweigand commented Jul 9, 2021

  • Fix mask shifting logic for big-endian systems

The mask shifting logic assumed little-endian byte order, which could lead to incorrectly decoded messages depending on buffer alignment. This caused failures in some aspnetcore tests (Microsoft.AspNetCore.SignalR.Client.FunctionalTests), which are fixed by this patch.

* Fix mask shifting logic for big-endian systems
@ghost ghost added the area-System.Net label Jul 9, 2021
@ghost
Copy link

ghost commented Jul 9, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Fix mask shifting logic for big-endian systems

The mask shifting logic assumed little-endian byte order, which could lead to incorrectly decoded messages depending on buffer alignment. This caused failures in some aspnetcore tests (Microsoft.AspNetCore.SignalR.Client.FunctionalTests), which are fixed by this patch.

Author: uweigand
Assignees: -
Labels:

area-System.Net

Milestone: -

@BrennanConroy
Copy link
Member

This caused failures in some aspnetcore tests (Microsoft.AspNetCore.SignalR.Client.FunctionalTests), which are fixed by this patch.

That's very interesting, those tests use Kestrel which doesn't support BigEndian, so not sure how they can pass with this change
https://github.com/dotnet/aspnetcore/blob/bb3737734e0c62b4863cc7d340e0c496a398a3d8/src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs#L145-L148

@uweigand
Copy link
Contributor Author

uweigand commented Jul 9, 2021

This caused failures in some aspnetcore tests (Microsoft.AspNetCore.SignalR.Client.FunctionalTests), which are fixed by this patch.

That's very interesting, those tests use Kestrel which doesn't support BigEndian, so not sure how they can pass with this change
https://github.com/dotnet/aspnetcore/blob/bb3737734e0c62b4863cc7d340e0c496a398a3d8/src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs#L145-L148

Ah, of course. I should have mentioned that I'm using a stack of patches on top of the aspnetcore code base as well, to fix endian issues in particular (mostly around string handling in Kestrel, including all that generated KnownHeaders code, but also around SockAddr processing, the RenderBatch stuff, and a few others).

I'm planning to submit those once I've cleaned them up a bit, but I wanted to go through the test suite failures first to make sure I'm not missing anything. That's when I ran into this issue, which is actually in the runtime, so I submitted this PR now just to get that out of the way.

@Tratcher
Copy link
Member

Tratcher commented Jul 9, 2021

What's the testing plan to avoid/catch big endian regressions in the future?

@uweigand
Copy link
Contributor Author

uweigand commented Jul 9, 2021

What's the testing plan to avoid/catch big endian regressions in the future?

Well, ideally we could get (big-endian) s390x machines into your CI environment. We have made machines available, and there's currently CI running on the s390x feature branch in runtimelab. Over time, we hope this can be moved over to the main runtime repo, and then also get enabled for some of the other major dotnet components, certainly including aspnetcore. There's still a ways to go to get there; in particular we don't have automated binary builds of the runtime/SDK for s390x yet - we're in discussions how to get that going.

As a fallback, we can always do regular runs of the test suites offline on our own machines as well.

@stephentoub stephentoub merged commit 3b8b527 into dotnet:main Jul 10, 2021
@uweigand uweigand deleted the bigendian-websockets branch July 14, 2021 12:19
@karelz karelz added this to the 6.0.0 milestone Jul 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants