Skip to content

exec: defer async reply teardown to avoid use-after-free#27

Merged
jow- merged 1 commit into
openwrt:masterfrom
wildmeng:submit/defer-async-exec-reply
Mar 16, 2026
Merged

exec: defer async reply teardown to avoid use-after-free#27
jow- merged 1 commit into
openwrt:masterfrom
wildmeng:submit/defer-async-exec-reply

Conversation

@wildmeng
Copy link
Copy Markdown

@wildmeng wildmeng commented Mar 16, 2026

This fixes a use-after-free in async exec handling.

When reply teardown runs directly from ustream callbacks, the callback call chain can still touch the freed exec context. Deferring completion through a 0 ms uloop timeout avoids freeing the context until the callbacks unwind.

@wildmeng wildmeng force-pushed the submit/defer-async-exec-reply branch from 2d14baa to c7293b6 Compare March 16, 2026 09:22
@wildmeng wildmeng changed the title exec,file: defer async reply teardown to avoid use-after-free defer async reply teardown to avoid use-after-free Mar 16, 2026
@wildmeng wildmeng force-pushed the submit/defer-async-exec-reply branch from c7293b6 to ecf45e4 Compare March 16, 2026 09:32
@wildmeng wildmeng changed the title defer async reply teardown to avoid use-after-free exec: defer async reply teardown to avoid use-after-free Mar 16, 2026
Async exec replies currently tear down their context directly from
ustream callbacks. When the callback chain keeps running after the
reply path frees the context, rpcd can hit a use-after-free and crash
with SIGSEGV.

Defer reply completion through a 0 ms uloop timeout and guard against
duplicate scheduling so cleanup runs after the callbacks unwind in both
exec paths.

Signed-off-by: Meng <x.meng@genexis.eu>
@wildmeng wildmeng force-pushed the submit/defer-async-exec-reply branch from ecf45e4 to e655a0d Compare March 16, 2026 09:34
@jow- jow- merged commit a4a5a29 into openwrt:master Mar 16, 2026
@jow-
Copy link
Copy Markdown
Contributor

jow- commented Mar 16, 2026

LGTM, merged!

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