Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

fix dereferencing uninitialized byte array in case recv() fails#30312

Merged
stephentoub merged 1 commit into
dotnet:masterfrom
wfurt:fix_29376
Jun 12, 2018
Merged

fix dereferencing uninitialized byte array in case recv() fails#30312
stephentoub merged 1 commit into
dotnet:masterfrom
wfurt:fix_29376

Conversation

@wfurt
Copy link
Copy Markdown
Member

@wfurt wfurt commented Jun 12, 2018

fixes #29376 [arm32/Ubuntu] corefx test failures: System.Net.NetworkInformation.Functional.Tests, System.Net.Sockets.Tests

related to #27411 Re-enable initlocals clearing in System.Net.Sockets on Unix

We disabled initialization of local variables for sockets. We pass buffer allocated via stackalloc() to get ancillary data. When recv() call fails (like with EAGAIN) the buffer is uninitialized and it is not safe to parse it and use data or pointers from it. This does not seems ARM specific bug. X86 may be just more lucky getting stack full of zeros. My initial POC was to initialize control buffer (24b) to zeros.so
That fixes the crash as well (by fining first message has 0 length) but I think this fix is better.
It would be nice IMHO if we do not need to allocate ipPacketInformation but that is beyond this fix.

I also briefly scan for other use of stackalloc() in sockets and the other place looks reasonable.

I re-run all (outerloop) test on ARM system and I see no crash. Four tests timed out - but the ARM system is MUCH slower so this may not be sign of real problem.

@wfurt wfurt added bug Product bug (most likely) os-linux Linux OS (any supported distro) area-System.Net.Sockets labels Jun 12, 2018
@wfurt wfurt self-assigned this Jun 12, 2018
@wfurt wfurt requested review from a team and stephentoub June 12, 2018 04:33
@wfurt
Copy link
Copy Markdown
Member Author

wfurt commented Jun 12, 2018

@dotnet-bot test Outerloop Windows x64 Debug Build
@dotnet-bot test Outerloop Linux x64 Debug Build
@dotnet-bot test Outerloop NETFX x86 Debug Build
@dotnet-bot test Outerloop UWP CoreCLR x64 Debug Build
@dotnet-bot test Outerloop OSX x64 Debug Build

Copy link
Copy Markdown
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for tracking it down and fixing it.

@stephentoub
Copy link
Copy Markdown
Member

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net.Sockets bug Product bug (most likely) os-linux Linux OS (any supported distro)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[arm32/Ubuntu] corefx test failures: System.Net.NetworkInformation.Functional.Tests, System.Net.Sockets.Tests

3 participants