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

injector: push apart overlapping traps #1739

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/libinjector/linux/linux_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ addr_t find_vdso(drakvuf_t drakvuf, drakvuf_trap_info_t* info)
addr_t find_syscall(drakvuf_t drakvuf, drakvuf_trap_info_t* info, addr_t vdso)
{
vmi_instance_t vmi = drakvuf_lock_and_get_vmi(drakvuf);
// skip the syscall we are currently on
addr_t skip_addr = info->regs->rip - 2;

ACCESS_CONTEXT(ctx,
.translate_mechanism = VMI_TM_PROCESS_PID,
Expand All @@ -202,6 +204,11 @@ addr_t find_syscall(drakvuf_t drakvuf, drakvuf_trap_info_t* info, addr_t vdso)

char syscall[] = { 0xf, 0x5 };
void* syscall_substring_address = memmem(vdso_memory, size, (void*)syscall, 2);
if (syscall_substring_address && (vdso + (syscall_substring_address - vdso_memory)) == skip_addr)
{
PRINT_DEBUG("Skip syscall offset, as it overlaps with current trap\n");
syscall_substring_address = memmem(syscall_substring_address + 1, size, (void*)syscall, 2);
}
int syscall_offset = 0;
if (!syscall_substring_address)
{
Expand Down
Loading