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>
@afrind
afrind force-pushed the fix/cross-exec-filter-uaf branch from 7b68750 to d3f389f Compare September 2, 2026 01:45

@gmarzot gmarzot 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.

@gmarzot reviewed 12 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on afrind).

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.

2 participants