-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "libc_less.c.inc" | ||
|
||
static unsigned long syscall_addr; | ||
|
||
static long do_remote_syscall(int pid, struct user_pt_regs *syscall_regs) { | ||
injectlib_stdout_write("performing remote syscall\n"); | ||
syscall_regs->pc = syscall_addr; | ||
struct iovec sysc_regs_vec = { .iov_base = syscall_regs, .iov_len = sizeof(*syscall_regs) }; | ||
// write back registers | ||
int srs_ret = injectlib_ptrace(PTRACE_SETREGSET, pid, (void*)NT_PRSTATUS, &sysc_regs_vec); | ||
if (srs_ret) { | ||
injectlib_stdout_write("PTRACE_SETREGSET failed\n"); | ||
while (1) {} /* fatal error */ | ||
} | ||
|
||
// step into and out of the syscall | ||
int ptrace_res = injectlib_ptrace(PTRACE_SYSCALL, pid, NULL, NULL); | ||
if (ptrace_res) { | ||
injectlib_stdout_write("PTRACE_SYSCALL(1) failed\n"); | ||
while (1) {} /* fatal error */ | ||
} | ||
injectlib_simple_wait(pid); | ||
ptrace_res = injectlib_ptrace(PTRACE_SYSCALL, pid, NULL, NULL); | ||
if (ptrace_res) { | ||
injectlib_stdout_write("PTRACE_SYSCALL(2) failed\n"); | ||
while (1) {} /* fatal error */ | ||
} | ||
injectlib_simple_wait(pid); | ||
|
||
int grs_ret = injectlib_ptrace(PTRACE_GETREGSET, pid, (void*)NT_PRSTATUS, &sysc_regs_vec); | ||
if (grs_ret) { | ||
injectlib_stdout_write("PTRACE_GETREGSET failed\n"); | ||
while (1) {} /* fatal error */ | ||
} | ||
|
||
injectlib_stdout_write("remote syscall done: "); | ||
injectlib_log_hexnum(syscall_regs->regs[0]); | ||
injectlib_stdout_write("\n"); | ||
return syscall_regs->regs[0]; | ||
} |
f31d1ae
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void _start(void) {
injectlib_stdout_write("hello from crash_dump!\n");
}