Skip to content

relay: defer CrossExecFilter destruction to its target executor - #654

Open
afrind wants to merge 1 commit into
mainfrom
fix/cross-exec-filter-uaf
Open

relay: defer CrossExecFilter destruction to its target executor#654
afrind wants to merge 1 commit into
mainfrom
fix/cross-exec-filter-uaf

Conversation

@afrind

@afrind afrind commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

CrossExecFilter's methods enqueue [this]-capturing lambdas on targetExec_, but nothing keeps the filter alive until they run — owners release it from whatever executor they happen to be on. It can be freed with calls still queued, and the lambda then reads downstream_ off freed memory, seen as a SIGSEGV in beginSubgroup on a v0.3.1 relay.

The sibling filters anchor themselves with selfGuard_, but that needs a terminal call and a TrackConsumer has none that is guaranteed. Destruction is guaranteed, so create() installs a deleter that posts the delete to targetExec_ behind every lambda already queued, and PrivateTag makes create() the only way to build one.

  auto filter = CrossExecFilter::create(targetExec, downstream);

This change is Reviewable

CrossExecFilter's methods enqueue [this]-capturing lambdas on targetExec_, but
nothing keeps the filter alive until they run — owners release it from whatever
executor they happen to be on. It can be freed with calls still queued, and the
lambda then reads downstream_ off freed memory, seen as a SIGSEGV in
beginSubgroup on a v0.3.1 relay.

The sibling filters anchor themselves with selfGuard_, but that needs a terminal
call and a TrackConsumer has none that is guaranteed. Destruction is guaranteed,
so create() installs a deleter that posts the delete to targetExec_ behind every
lambda already queued, and PrivateTag makes create() the only way to build one.

  auto filter = CrossExecFilter::create(targetExec, downstream);

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant