Skip to content

posix: fix use-after-free when name resolution is abandoned - #347

Merged
vincent-richard merged 2 commits into
masterfrom
273-posixsocketresolve-may-wreak-havoc
Oct 23, 2026
Merged

vincent-richard merged 2 commits into
masterfrom
273-posixsocketresolve-may-wreak-havoc

Conversation

@vincent-richard

Copy link
Copy Markdown
Member

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.

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.
@vincent-richard vincent-richard linked an issue Oct 4, 2026 that may be closed by this pull request
@vincent-richard
vincent-richard merged commit b34fa2d into master Oct 23, 2026
7 checks passed
@vincent-richard
vincent-richard deleted the 273-posixsocketresolve-may-wreak-havoc branch October 23, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

posixSocket::resolve may wreak havoc

1 participant