Skip to content

multi: forbid curl_easy_pause from within multi socket callback#22179

Closed
bagder wants to merge 9 commits into
masterfrom
bagder/socket-cb-pause
Closed

multi: forbid curl_easy_pause from within multi socket callback#22179
bagder wants to merge 9 commits into
masterfrom
bagder/socket-cb-pause

Conversation

@bagder

@bagder bagder commented Jun 25, 2026

Copy link
Copy Markdown
Member
  • 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

- 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
@bagder bagder marked this pull request as ready for review June 25, 2026 21:27
@bagder bagder requested a review from Copilot June 25, 2026 21:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_callback tracking value on Curl_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.

Comment thread lib/easy.c Outdated
Comment thread lib/easy.c Outdated
Comment thread lib/multi.c Outdated
Comment thread lib/multi_ev.c
Comment thread lib/multi_ev.c
Comment thread lib/multihandle.h Outdated
Comment thread docs/libcurl/curl_easy_pause.md
@github-actions github-actions Bot added the tests label Jun 26, 2026
@bagder bagder requested a review from icing June 26, 2026 06:58

@icing icing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Except the one comment, looks fine!

Comment thread lib/easy.c Outdated
@bagder bagder closed this in a6af50c Jun 26, 2026
@bagder bagder deleted the bagder/socket-cb-pause branch June 26, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants