Repository navigation
posix: fix use-after-free when name resolution is abandoned - #347
Merged
Merged
Conversation
posixSocket::resolve() passed stack variables (and the caller's address string) to getaddrinfo_a(). When the timeout handler aborted the loop while the request was still being processed, glibc kept reading these and wrote the result into a dead stack frame, corrupting the stack. The request now lives on the heap with its own copies of the data. When leaving resolve(), it is deleted if glibc is done with it (or if it can still be cancelled); otherwise, its deletion is deferred to a later call. Also, keep waiting when gai_suspend() is interrupted by a signal (EAI_INTR), instead of failing and abandoning the request. Fixes #273.
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.
posixSocket::resolve() passed stack variables (and the caller's address string) to getaddrinfo_a(). When the timeout handler aborted the loop while the request was still being processed, glibc kept reading these and wrote the result into a dead stack frame, corrupting the stack.
The request now lives on the heap with its own copies of the data. When leaving resolve(), it is deleted if glibc is done with it (or if it can still be cancelled); otherwise, its deletion is deferred to a later call.
Also, keep waiting when gai_suspend() is interrupted by a signal (EAI_INTR), instead of failing and abandoning the request.
Fixes #273.