multi: forbid curl_easy_pause from within multi socket callback#22179
Closed
bagder wants to merge 9 commits into
Closed
multi: forbid curl_easy_pause from within multi socket callback#22179bagder wants to merge 9 commits into
bagder wants to merge 9 commits into
Conversation
- there is a risk for a nasty recursive situation - we avoid certain risks that the pause call changes things so that when returning from the callback, the state of certain internals is undefined and we need to reload which is easy to miss - we can't think of legitiate use cases for doing this. This is basically just the new favorite point for AI and security researchers to find hypothetical problems
There was a problem hiding this comment.
Pull request overview
This PR tightens libcurl’s multi-socket callback re-entrancy rules by explicitly disallowing curl_easy_pause() from being called inside the CURLMOPT_SOCKETFUNCTION callback, aiming to avoid recursive re-entry and internal state invalidation.
Changes:
- Introduces a 3-state
in_callbacktracking value onCurl_multi(including a “forbid easy_pause” state). - Wraps multi socket callback invocations with a state that forbids
curl_easy_pause(). - Updates
curl_easy_pause(3)documentation to note the socket-callback exception.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/multiif.h | Changes Curl_is_in_callback() to return a multi-state value (uint8_t). |
| lib/multihandle.h | Adds callback-state constants and changes Curl_multi to store in_callback as uint8_t. |
| lib/multi.c | Implements the new multi-state callback tracking getter/setter behavior. |
| lib/multi_ev.c | Marks socket callback execution as a context that forbids curl_easy_pause(). |
| lib/easy.c | Makes curl_easy_pause() reject calls made from the forbidden socket-callback context. |
| docs/libcurl/curl_easy_pause.md | Documents the new restriction for socket callbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
icing
reviewed
Jun 26, 2026
icing
left a comment
Contributor
There was a problem hiding this comment.
Except the one comment, looks fine!
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.
there is a risk for a nasty recursive situation
we avoid certain risks that the pause call changes things so that when returning from the callback, the state of certain internals is undefined and we need to reload which is easy to miss
we can't think of legitimate use cases for doing this. This is basically just the new favorite point for AI and security researchers to find hypothetical problems