diff options
author | Mike Frysinger <vapier@gentoo.org> | 2012-07-03 00:45:41 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2012-07-03 14:27:45 -0400 |
commit | 731630b7470b2b7ae3c055779138460d14d9fcd5 (patch) | |
tree | 5f4d373a2f4032789515ca1a608956b76ec17f6d /libsandbox/trace.c | |
parent | include stdint.h/inttypes.h too (diff) | |
download | sandbox-731630b7470b2b7ae3c055779138460d14d9fcd5.tar.gz sandbox-731630b7470b2b7ae3c055779138460d14d9fcd5.tar.bz2 sandbox-731630b7470b2b7ae3c055779138460d14d9fcd5.zip |
libsandbox: migrate to get/set regs interface for everyone
Newer ports (like x32) limit what is available via the peek/poke user
interface, and instead are pushing people to use the single get/set
regs interface. Since this also simplifies the code a bit (by forcing
all ports to use this), and cuts down on the number of syscalls that
we have to make, switch everyone over to it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsandbox/trace.c')
-rw-r--r-- | libsandbox/trace.c | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/libsandbox/trace.c b/libsandbox/trace.c index a7b7c02..f2071e0 100644 --- a/libsandbox/trace.c +++ b/libsandbox/trace.c @@ -70,16 +70,6 @@ static long _do_ptrace(enum __ptrace_request request, const char *srequest, void return ret; } -static long do_peekuser(long offset) -{ - return do_ptrace(PTRACE_PEEKUSER, (void *)offset, NULL); -} - -static long do_pokeuser(long offset, long val) -{ - return do_ptrace(PTRACE_POKEUSER, (void *)offset, (void *)val); -} - static long do_peekdata(long offset) { return do_ptrace(PTRACE_PEEKDATA, (void *)offset, NULL); @@ -205,10 +195,6 @@ static const struct syscall_entry *lookup_syscall_in_tbl(const struct syscall_en ++tbl; return NULL; } -static const struct syscall_entry *lookup_syscall(int nr) -{ - return lookup_syscall_in_tbl(trace_check_personality(), nr); -} struct syscall_state { void *regs; @@ -382,42 +368,27 @@ static bool trace_check_syscall(const struct syscall_entry *se, void *regs) return ret; } -/* Some arches (like hppa) don't implement PTRACE_GETREGS, while others (like - * sparc) swap the meaning of "addr" and "data. What a bunch of asshats. - */ -#ifndef trace_get_regs -# define trace_get_regs(regs) do_ptrace(PTRACE_GETREGS, NULL, regs) -#endif -#ifndef trace_set_regs -# define trace_set_regs(regs) do_ptrace(PTRACE_SETREGS, NULL, regs) -#endif -/* Some arches (like sparc) don't implement PTRACE_PEEK* ... - * more asshats ! - */ -#ifndef trace_sysnum_regs -# define trace_sysnum_regs(regs) trace_sysnum() -#endif - static void trace_loop(void) { trace_regs regs; bool before_syscall, fake_syscall_ret; long ret; int nr, exec_state; - const struct syscall_entry *se, *tbl_at_fork; + const struct syscall_entry *se, *tbl_at_fork, *tbl_after_fork; exec_state = 0; before_syscall = true; fake_syscall_ret = false; - tbl_at_fork = NULL; + tbl_at_fork = tbl_after_fork = NULL; do { ret = do_ptrace(PTRACE_SYSCALL, NULL, NULL); waitpid(trace_pid, NULL, 0); - nr = trace_sysnum_regs(®s); + ret = trace_get_regs(®s); + nr = trace_get_sysnum(®s); if (!exec_state) { if (!tbl_at_fork) - tbl_at_fork = trace_check_personality(); + tbl_at_fork = trace_check_personality(®s); se = lookup_syscall_in_tbl(tbl_at_fork, nr); if (!before_syscall || !se || se->sys != SB_NR_EXECVE) { if (before_syscall) @@ -433,7 +404,9 @@ static void trace_loop(void) goto loop_again; } - se = lookup_syscall(nr); + if (!tbl_after_fork) + tbl_after_fork = trace_check_personality(®s); + se = lookup_syscall_in_tbl(tbl_after_fork, nr); ret = trace_get_regs(®s); if (before_syscall) { _sb_debug("%s:%i", se ? se->name : "IDK", nr); |