Skip to content

aarch64: Fix context refcount leak on SVC dispatch#2171

Open
robertream wants to merge 1 commit into
nanovms:masterfrom
robertream:fix/aarch64-syscall-refcount-leak
Open

aarch64: Fix context refcount leak on SVC dispatch#2171
robertream wants to merge 1 commit into
nanovms:masterfrom
robertream:fix/aarch64-syscall-refcount-leak

Conversation

@robertream

Copy link
Copy Markdown

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.

`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 francescolavra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

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