aarch64: Fix context refcount leak on SVC dispatch#2171
Open
robertream wants to merge 1 commit into
Open
Conversation
`synchronous_handler` acquires a refcount but only releases it on the fault path, leaking one ref per syscall. Since syscall_handler takes its own refcount, we can safely release the initial refcount before syscall dispatch.
francescolavra
requested changes
Jul 5, 2026
francescolavra
left a comment
Member
There was a problem hiding this comment.
Nice find!
However, it would be better to not not acquire the refcount at all (in synchronous_handler()) when taking the syscall path, instead of acquiring it and then releasing it. Also, setting f[FRAME_FULL] = true is redundant in the syscall path, since syscall_handler() does that.
So I think the correct fix would be to move the following 2 lines in synchronous_handler() so they are just before fault_handler fh = ctx->fault_handler.
f[FRAME_FULL] = true;
context_reserve_refcount(ctx);
By the way, the same bug is also present in the riscv64 code, in trap_exception(), and the same fix should be applied there too.
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.
synchronous_handleracquires a refcount but only releases it on the fault path, leaking one ref per syscall. Since syscall_handler takes its own refcount, we can safely release the initial refcount before syscall dispatch.