Repository navigation
unix: validate control message data length before unsafe cast - #298
Open
TristanInSec wants to merge 2 commits into
Open
TristanInSec wants to merge 2 commits into
TristanInSec wants to merge 2 commits into
Conversation
FdSet.Set, Clear, and IsSet do not validate the fd parameter before indexing into fds.Bits, causing a runtime panic when fd >= FD_SETSIZE (1024) or fd < 0. Add bounds checks consistent with the CPUSet helpers in affinity_linux.go, which already guard against out-of-range indices.
ParseUnixCredentials and ParseOrigDstAddr access m.Data[0] via unsafe.Pointer without first checking that m.Data is large enough to hold the target struct. When the control message header has Len equal to SizeofCmsghdr (no payload), m.Data is empty and the index panics. Add length checks before each unsafe.Pointer cast, consistent with how other parsers in the standard library validate input sizes before reinterpret casts.
Contributor
|
This PR (HEAD: 09ddead) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/sys/+/857702. Important tips:
|
Contributor
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/857702. |
Contributor
|
Message from Ian Lance Taylor: Patch Set 1: (4 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/857702. |
Contributor
|
Message from Tobias Klauser: Patch Set 1: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/857702. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ParseUnixCredentials and ParseOrigDstAddr access m.Data[0] via unsafe.Pointer without first checking that m.Data is large enough to hold the target struct. When the control message header has Len equal to SizeofCmsghdr (no payload), m.Data is empty and the index panics.
This adds length checks before each unsafe.Pointer cast: