Skip to content

Commit

Permalink
Change way to update syscall number for arm64
Browse files Browse the repository at this point in the history
 In fact what was choose to update syscall for arm64 is not
PTRACE_SET_SYSCALL but PTRACE_SETREGSET with NT_ARM_SYSTEM_CALL
subcommand. See kernel commit
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=766a85d7bc5d7f1ddd6de28bdb844eae45ec63b0
  • Loading branch information
mickael-guene committed Feb 20, 2015
1 parent dcf0908 commit b06b8d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/compat.h
Expand Up @@ -243,5 +243,9 @@
# ifndef MAP_ANONYMOUS
# define MAP_ANONYMOUS 0x20
# endif
/* This one should disappear once it has been put on headers */
# ifndef NT_ARM_SYSTEM_CALL
# define NT_ARM_SYSTEM_CALL 0x404
# endif

#endif /* COMPAT_H */
11 changes: 8 additions & 3 deletions src/tracee/reg.c
Expand Up @@ -300,16 +300,21 @@ int push_regs(Tracee *tracee)
}

#if defined(ARCH_ARM64)
/* as On ARM we need to use PTRACE_SET_SYSCALL to change syscall number */
/* For arm64 a new subcommand has been add to PTRACE_SETREGSET/PTRACE_GETREGSET to
allow write/read of current sycall number */
struct iovec regs;
word_t current_sysnum = REG(tracee, CURRENT, SYSARG_NUM);
unsigned int current_sysnum = (int) REG(tracee, CURRENT, SYSARG_NUM);

/* update syscall number if needed */
if (current_sysnum != REG(tracee, ORIGINAL, SYSARG_NUM)) {
status = ptrace(PTRACE_SET_SYSCALL, tracee->pid, 0, current_sysnum);
regs.iov_base = &current_sysnum;
regs.iov_len = sizeof(current_sysnum);
status = ptrace(PTRACE_SETREGSET, tracee->pid, NT_ARM_SYSTEM_CALL, &regs);
if (status < 0)
note(tracee, WARNING, SYSTEM, "can't set the syscall number");
}

/* update remaining of registers */
regs.iov_base = &tracee->_regs[CURRENT];
regs.iov_len = sizeof(tracee->_regs[CURRENT]);

Expand Down

0 comments on commit b06b8d0

Please sign in to comment.