Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix libinjector timeouts #1455

Merged
merged 3 commits into from
May 31, 2022

Conversation

piotr-krysiuk
Copy link
Contributor

libinjector, win: Fix intermittent timeouts

After restoring the saved CPU registers, each injection method waits
for the next trap before exiting the injector loop. This means that
the target thread, continuing to execute the original program, needs
to trigger the same trap before the injector can finish. And that leads
to unpredictable waits. For example, waits of a few minutes were
observed when testing injector against explorer.exe under Windows 7
Enterprise (x64). Further, injector could wait forever in case the
target thread never revisits the trap.

The waits were introduced when refactoring injection methods in commit
3fdb370 ("win_injector: seperate readfile and writefile to
different files (#1319)").

Fix this issue by arranging for the injector loop to exit immediately
after restoring the saved CPU registers.

Pass drakvuf as explicit argument to simplify a future commit. This
also improves consistency with the corresponding code for Linux.
After restoring the saved CPU registers, each injection method waits
for the next trap before exiting the injector loop. This means that
the target thread, continuing to execute the original program, needs
to trigger the same trap before the injector can finish. And that leads
to unpredictable waits. For example, waits of a few minutes were
observed when testing injector against explorer.exe under Windows 7
Enterprise (x64). Further, injector could wait forever in case the
target thread never revisits the trap.

The waits were introduced when refactoring injection methods in commit
3fdb370 ("win_injector: seperate readfile and writefile to
different files  (tklengyel#1319)").

Fix this issue by arranging for the injector loop to exit immediately
after restoring the saved CPU registers.
Use SIGINT instead of SIGDRAKVUFERROR when the injector succeeded.
@drakvuf-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@tklengyel
Copy link
Owner

@drakvuf-jenkins This is OK to test

@tklengyel tklengyel merged commit a39cfed into tklengyel:master May 31, 2022
@tklengyel
Copy link
Owner

Thanks for the PR!

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.

3 participants