From: Dmitry V. Levin Date: Wed, 5 Dec 2018 06:47:35 +0000 (+0000) Subject: Refactor get_syscall_args() and get_error() X-Git-Tag: v4.26~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=51d89ef0a02e20b0708fe06abde5b9756fe7fb95;p=strace Refactor get_syscall_args() and get_error() * linux/*/get_error.c: Rename all arch-specific implementations of get_error() to arch_get_error(). * linux/*/get_syscall_args.c: Rename all arch-specific implementations of get_syscall_args() to arch_get_syscall_args(). * syscall.c (get_syscall_args, get_error): New functions. (tamper_with_syscall_exiting, get_syscall_result): Do not clear tcp->u_error before get_error() invocation as the latter does it now. --- diff --git a/linux/aarch64/get_error.c b/linux/aarch64/get_error.c index b3287a0d..ab9fad79 100644 --- a/linux/aarch64/get_error.c +++ b/linux/aarch64/get_error.c @@ -1,11 +1,11 @@ #include "negated_errno.h" -#define get_error arm_get_error +#define arch_get_error arm_get_error #include "arm/get_error.c" -#undef get_error +#undef arch_get_error static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (tcp->currpers == 1) { arm_get_error(tcp, check_errno); diff --git a/linux/aarch64/get_syscall_args.c b/linux/aarch64/get_syscall_args.c index ea6e497d..f167e809 100644 --- a/linux/aarch64/get_syscall_args.c +++ b/linux/aarch64/get_syscall_args.c @@ -1,10 +1,10 @@ -#define get_syscall_args arm_get_syscall_args +#define arch_get_syscall_args arm_get_syscall_args #include "arm/get_syscall_args.c" -#undef get_syscall_args +#undef arch_get_syscall_args /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { if (tcp->currpers == 1) return arm_get_syscall_args(tcp); diff --git a/linux/alpha/get_error.c b/linux/alpha/get_error.c index d4928d4b..379348b6 100644 --- a/linux/alpha/get_error.c +++ b/linux/alpha/get_error.c @@ -1,5 +1,5 @@ static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (alpha_a3) { tcp->u_rval = -1; diff --git a/linux/alpha/get_syscall_args.c b/linux/alpha/get_syscall_args.c index be61abfa..2e39b844 100644 --- a/linux/alpha/get_syscall_args.c +++ b/linux/alpha/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { unsigned int i; diff --git a/linux/arc/get_error.c b/linux/arc/get_error.c index 39b5d1c0..88f9c83d 100644 --- a/linux/arc/get_error.c +++ b/linux/arc/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(arc_regs.scratch.r0)) { tcp->u_rval = -1; diff --git a/linux/arc/get_syscall_args.c b/linux/arc/get_syscall_args.c index 85e867f0..acf5778c 100644 --- a/linux/arc/get_syscall_args.c +++ b/linux/arc/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { unsigned long *arc_args = &arc_regs.scratch.r0; unsigned int i; diff --git a/linux/arm/get_error.c b/linux/arm/get_error.c index 02d7e65d..9cd53d2e 100644 --- a/linux/arm/get_error.c +++ b/linux/arm/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(arm_regs.ARM_r0)) { tcp->u_rval = -1; diff --git a/linux/arm/get_syscall_args.c b/linux/arm/get_syscall_args.c index 6be17501..007b9e60 100644 --- a/linux/arm/get_syscall_args.c +++ b/linux/arm/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = arm_regs.uregs[0]; tcp->u_arg[1] = arm_regs.uregs[1]; diff --git a/linux/avr32/get_error.c b/linux/avr32/get_error.c index b53c8f6c..654e6b98 100644 --- a/linux/avr32/get_error.c +++ b/linux/avr32/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(avr32_regs.r12)) { tcp->u_rval = -1; diff --git a/linux/avr32/get_syscall_args.c b/linux/avr32/get_syscall_args.c index e8c41198..90fbfafb 100644 --- a/linux/avr32/get_syscall_args.c +++ b/linux/avr32/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = avr32_regs.r12; tcp->u_arg[1] = avr32_regs.r11; diff --git a/linux/bfin/get_error.c b/linux/bfin/get_error.c index 76e4099d..98abd722 100644 --- a/linux/bfin/get_error.c +++ b/linux/bfin/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(bfin_r0)) { tcp->u_rval = -1; diff --git a/linux/bfin/get_syscall_args.c b/linux/bfin/get_syscall_args.c index 506d3a99..3d0e908f 100644 --- a/linux/bfin/get_syscall_args.c +++ b/linux/bfin/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { static const int argreg[MAX_ARGS] = { PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5 diff --git a/linux/hppa/get_error.c b/linux/hppa/get_error.c index 8b23f305..5ce449ac 100644 --- a/linux/hppa/get_error.c +++ b/linux/hppa/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(hppa_r28)) { tcp->u_rval = -1; diff --git a/linux/hppa/get_syscall_args.c b/linux/hppa/get_syscall_args.c index aa938f50..b58f8d70 100644 --- a/linux/hppa/get_syscall_args.c +++ b/linux/hppa/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { unsigned int i; diff --git a/linux/i386/get_error.c b/linux/i386/get_error.c index 9e0be03e..89de8113 100644 --- a/linux/i386/get_error.c +++ b/linux/i386/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(i386_regs.eax)) { tcp->u_rval = -1; diff --git a/linux/i386/get_syscall_args.c b/linux/i386/get_syscall_args.c index d5de1d95..353bde02 100644 --- a/linux/i386/get_syscall_args.c +++ b/linux/i386/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = i386_regs.ebx; tcp->u_arg[1] = i386_regs.ecx; diff --git a/linux/ia64/get_error.c b/linux/ia64/get_error.c index 61110779..1ce7be86 100644 --- a/linux/ia64/get_error.c +++ b/linux/ia64/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (ia64_regs.gr[10]) { tcp->u_rval = -1; diff --git a/linux/ia64/get_syscall_args.c b/linux/ia64/get_syscall_args.c index ad73c547..040e5c7b 100644 --- a/linux/ia64/get_syscall_args.c +++ b/linux/ia64/get_syscall_args.c @@ -2,7 +2,7 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { unsigned long *rbs_end = (unsigned long *) ia64_regs.ar[PT_AUR_BSP]; diff --git a/linux/m68k/get_error.c b/linux/m68k/get_error.c index edd69cfc..3a0472c1 100644 --- a/linux/m68k/get_error.c +++ b/linux/m68k/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(m68k_regs.d0)) { tcp->u_rval = -1; diff --git a/linux/m68k/get_syscall_args.c b/linux/m68k/get_syscall_args.c index 8ec3d281..a95db471 100644 --- a/linux/m68k/get_syscall_args.c +++ b/linux/m68k/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = m68k_regs.d1; tcp->u_arg[1] = m68k_regs.d2; diff --git a/linux/metag/get_error.c b/linux/metag/get_error.c index 5415b39b..afdec9d7 100644 --- a/linux/metag/get_error.c +++ b/linux/metag/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { /* result pointer in D0Re0 (D0.0) */ if (check_errno && is_negated_errno(metag_regs.dx[0][0])) { diff --git a/linux/metag/get_syscall_args.c b/linux/metag/get_syscall_args.c index 4cae04f1..c11de145 100644 --- a/linux/metag/get_syscall_args.c +++ b/linux/metag/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { unsigned int i; diff --git a/linux/microblaze/get_error.c b/linux/microblaze/get_error.c index 1da69c0e..fb529ff8 100644 --- a/linux/microblaze/get_error.c +++ b/linux/microblaze/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(microblaze_r3)) { tcp->u_rval = -1; diff --git a/linux/microblaze/get_syscall_args.c b/linux/microblaze/get_syscall_args.c index 1a3a48f9..19314204 100644 --- a/linux/microblaze/get_syscall_args.c +++ b/linux/microblaze/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { unsigned int i; diff --git a/linux/mips/get_error.c b/linux/mips/get_error.c index 4096de26..6bf6b20e 100644 --- a/linux/mips/get_error.c +++ b/linux/mips/get_error.c @@ -1,5 +1,5 @@ static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (mips_REG_A3) { tcp->u_rval = -1; diff --git a/linux/mips/get_syscall_args.c b/linux/mips/get_syscall_args.c index 3c9160e3..ec360243 100644 --- a/linux/mips/get_syscall_args.c +++ b/linux/mips/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { #if defined LINUX_MIPSN64 || defined LINUX_MIPSN32 tcp->u_arg[0] = mips_REG_A0; diff --git a/linux/nios2/get_error.c b/linux/nios2/get_error.c index 1c91c0ac..0dc66fba 100644 --- a/linux/nios2/get_error.c +++ b/linux/nios2/get_error.c @@ -1,5 +1,5 @@ static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { /* * The system call convention specifies that r2 contains the return diff --git a/linux/nios2/get_syscall_args.c b/linux/nios2/get_syscall_args.c index 707f594a..d71d29cd 100644 --- a/linux/nios2/get_syscall_args.c +++ b/linux/nios2/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = nios2_regs.regs[4]; tcp->u_arg[1] = nios2_regs.regs[5]; diff --git a/linux/or1k/get_error.c b/linux/or1k/get_error.c index f6a32713..f6977581 100644 --- a/linux/or1k/get_error.c +++ b/linux/or1k/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(or1k_regs.gpr[11])) { tcp->u_rval = -1; diff --git a/linux/or1k/get_syscall_args.c b/linux/or1k/get_syscall_args.c index b72e01f0..17e41dca 100644 --- a/linux/or1k/get_syscall_args.c +++ b/linux/or1k/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = or1k_regs.gpr[3 + 0]; tcp->u_arg[1] = or1k_regs.gpr[3 + 1]; diff --git a/linux/powerpc/get_error.c b/linux/powerpc/get_error.c index 8f10612d..7aa7808b 100644 --- a/linux/powerpc/get_error.c +++ b/linux/powerpc/get_error.c @@ -1,5 +1,5 @@ static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (ppc_regs.ccr & 0x10000000) { tcp->u_rval = -1; diff --git a/linux/powerpc/get_syscall_args.c b/linux/powerpc/get_syscall_args.c index b54377ef..471bf08f 100644 --- a/linux/powerpc/get_syscall_args.c +++ b/linux/powerpc/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { if (current_personality != 0) { /* diff --git a/linux/riscv/get_error.c b/linux/riscv/get_error.c index 2b2594fc..8bec778e 100644 --- a/linux/riscv/get_error.c +++ b/linux/riscv/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(riscv_regs.a0)) { tcp->u_rval = -1; diff --git a/linux/riscv/get_syscall_args.c b/linux/riscv/get_syscall_args.c index 746e085c..a79fa445 100644 --- a/linux/riscv/get_syscall_args.c +++ b/linux/riscv/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = riscv_regs.a0; tcp->u_arg[1] = riscv_regs.a1; diff --git a/linux/s390/get_error.c b/linux/s390/get_error.c index 6f3925be..e7c16324 100644 --- a/linux/s390/get_error.c +++ b/linux/s390/get_error.c @@ -5,7 +5,7 @@ #endif static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(ARCH_REGSET.gprs[2])) { tcp->u_rval = -1; diff --git a/linux/s390/get_syscall_args.c b/linux/s390/get_syscall_args.c index 2c353807..881dc95d 100644 --- a/linux/s390/get_syscall_args.c +++ b/linux/s390/get_syscall_args.c @@ -4,7 +4,7 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = ARCH_REGSET.orig_gpr2; tcp->u_arg[1] = ARCH_REGSET.gprs[3]; diff --git a/linux/s390x/get_error.c b/linux/s390x/get_error.c index fe503f46..c30b317f 100644 --- a/linux/s390x/get_error.c +++ b/linux/s390x/get_error.c @@ -1,19 +1,19 @@ #include "negated_errno.h" -#define get_error s390_get_error +#define arch_get_error s390_get_error #define ARCH_REGSET s390_regset #include "../s390/get_error.c" #undef ARCH_REGSET -#undef get_error +#undef arch_get_error -#define get_error s390x_get_error +#define arch_get_error s390x_get_error #define ARCH_REGSET s390x_regset #include "../s390/get_error.c" #undef ARCH_REGSET -#undef get_error +#undef arch_get_error static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (tcp->currpers == 1) s390_get_error(tcp, check_errno); diff --git a/linux/s390x/get_syscall_args.c b/linux/s390x/get_syscall_args.c index bed3d68f..5dcab261 100644 --- a/linux/s390x/get_syscall_args.c +++ b/linux/s390x/get_syscall_args.c @@ -1,18 +1,18 @@ -#define get_syscall_args s390_get_syscall_args +#define arch_get_syscall_args s390_get_syscall_args #define ARCH_REGSET s390_regset #include "../s390/get_syscall_args.c" #undef ARCH_REGSET -#undef get_syscall_args +#undef arch_get_syscall_args -#define get_syscall_args s390x_get_syscall_args +#define arch_get_syscall_args s390x_get_syscall_args #define ARCH_REGSET s390x_regset #include "../s390/get_syscall_args.c" #undef ARCH_REGSET -#undef get_syscall_args +#undef arch_get_syscall_args /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { if (tcp->currpers == 1) return s390_get_syscall_args(tcp); diff --git a/linux/sh/get_error.c b/linux/sh/get_error.c index 0bb6fc50..2cd1a6b2 100644 --- a/linux/sh/get_error.c +++ b/linux/sh/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(sh_r0)) { tcp->u_rval = -1; diff --git a/linux/sh/get_syscall_args.c b/linux/sh/get_syscall_args.c index b4ee1dd3..15f77b91 100644 --- a/linux/sh/get_syscall_args.c +++ b/linux/sh/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { static const int syscall_regs[MAX_ARGS] = { 4 * (REG_REG0+4), diff --git a/linux/sh64/get_error.c b/linux/sh64/get_error.c index 0a9001d8..b3971600 100644 --- a/linux/sh64/get_error.c +++ b/linux/sh64/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(sh64_r9)) { tcp->u_rval = -1; diff --git a/linux/sh64/get_syscall_args.c b/linux/sh64/get_syscall_args.c index e35c3507..5a387326 100644 --- a/linux/sh64/get_syscall_args.c +++ b/linux/sh64/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { /* Registers used by SH5 Linux system calls for parameters */ static const int syscall_regs[MAX_ARGS] = { 2, 3, 4, 5, 6, 7 }; diff --git a/linux/sparc/get_error.c b/linux/sparc/get_error.c index b41bfb37..03d774b0 100644 --- a/linux/sparc/get_error.c +++ b/linux/sparc/get_error.c @@ -1,7 +1,7 @@ #include static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (sparc_regs.psr & PSR_C) { tcp->u_rval = -1; diff --git a/linux/sparc/get_syscall_args.c b/linux/sparc/get_syscall_args.c index 57b5488e..0ab8b3c2 100644 --- a/linux/sparc/get_syscall_args.c +++ b/linux/sparc/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = sparc_regs.u_regs[U_REG_O0 + 0]; tcp->u_arg[1] = sparc_regs.u_regs[U_REG_O0 + 1]; diff --git a/linux/sparc64/get_error.c b/linux/sparc64/get_error.c index 8f8978b6..fcf60ae6 100644 --- a/linux/sparc64/get_error.c +++ b/linux/sparc64/get_error.c @@ -1,5 +1,5 @@ static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (sparc_regs.tstate & 0x1100000000UL) { tcp->u_rval = -1; diff --git a/linux/sparc64/get_syscall_args.c b/linux/sparc64/get_syscall_args.c index f5c1aa6f..00dbf894 100644 --- a/linux/sparc64/get_syscall_args.c +++ b/linux/sparc64/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { if (tcp->currpers == 1) { /* diff --git a/linux/tile/get_error.c b/linux/tile/get_error.c index 1f007bad..ae8ecbd3 100644 --- a/linux/tile/get_error.c +++ b/linux/tile/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { /* * The standard tile calling convention returns the value diff --git a/linux/tile/get_syscall_args.c b/linux/tile/get_syscall_args.c index b2043d39..c27339bd 100644 --- a/linux/tile/get_syscall_args.c +++ b/linux/tile/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { tcp->u_arg[0] = tile_regs.regs[0]; tcp->u_arg[1] = tile_regs.regs[1]; diff --git a/linux/x86_64/get_error.c b/linux/x86_64/get_error.c index ac47ab58..927e46ca 100644 --- a/linux/x86_64/get_error.c +++ b/linux/x86_64/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { /* * In X32, return value is 64-bit (llseek uses one). diff --git a/linux/x86_64/get_syscall_args.c b/linux/x86_64/get_syscall_args.c index f285ac32..45b0460d 100644 --- a/linux/x86_64/get_syscall_args.c +++ b/linux/x86_64/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { if (x86_io.iov_len != sizeof(i386_regs)) { /* x86-64 or x32 ABI */ diff --git a/linux/xtensa/get_error.c b/linux/xtensa/get_error.c index f49cc467..0c38470c 100644 --- a/linux/xtensa/get_error.c +++ b/linux/xtensa/get_error.c @@ -1,7 +1,7 @@ #include "negated_errno.h" static void -get_error(struct tcb *tcp, const bool check_errno) +arch_get_error(struct tcb *tcp, const bool check_errno) { if (check_errno && is_negated_errno(xtensa_a2)) { tcp->u_rval = -1; diff --git a/linux/xtensa/get_syscall_args.c b/linux/xtensa/get_syscall_args.c index 2a20cdb1..ca3aeec5 100644 --- a/linux/xtensa/get_syscall_args.c +++ b/linux/xtensa/get_syscall_args.c @@ -1,6 +1,6 @@ /* Return -1 on error or 1 on success (never 0!). */ static int -get_syscall_args(struct tcb *tcp) +arch_get_syscall_args(struct tcb *tcp) { /* arg0: a6, arg1: a3, arg2: a4, arg3: a5, arg4: a8, arg5: a9 */ static const int xtensaregs[MAX_ARGS] = { diff --git a/syscall.c b/syscall.c index 9107fe50..9ff95591 100644 --- a/syscall.c +++ b/syscall.c @@ -477,9 +477,11 @@ print_err_ret(kernel_ulong_t ret, unsigned long u_error) static long get_regs(struct tcb *); static int get_syscall_args(struct tcb *); static int get_syscall_result(struct tcb *); +static void get_error(struct tcb *, bool); static int arch_get_scno(struct tcb *tcp); static int arch_set_scno(struct tcb *, kernel_ulong_t); -static void get_error(struct tcb *, const bool); +static int arch_get_syscall_args(struct tcb *); +static void arch_get_error(struct tcb *, bool); static int arch_set_error(struct tcb *); static int arch_set_success(struct tcb *); @@ -591,10 +593,8 @@ tamper_with_syscall_exiting(struct tcb *tcp) } } - if (update_tcb) { - tcp->u_error = 0; + if (update_tcb) get_error(tcp, !(tcp->s_ent->sys_flags & SYSCALL_NEVER_FAILS)); - } return 0; } @@ -1265,6 +1265,12 @@ get_scno(struct tcb *tcp) return 1; } +static int +get_syscall_args(struct tcb *tcp) +{ + return arch_get_syscall_args(tcp); +} + #ifdef ptrace_getregset_or_getregs # define get_syscall_result_regs get_regs #else @@ -1281,7 +1287,6 @@ get_syscall_result(struct tcb *tcp) { if (get_syscall_result_regs(tcp) < 0) return -1; - tcp->u_error = 0; get_error(tcp, (!(tcp->s_ent->sys_flags & SYSCALL_NEVER_FAILS) || syscall_tampered(tcp)) @@ -1290,6 +1295,13 @@ get_syscall_result(struct tcb *tcp) return 1; } +static void +get_error(struct tcb *tcp, const bool check_errno) +{ + tcp->u_error = 0; + arch_get_error(tcp, check_errno); +} + #include "get_scno.c" #include "set_scno.c" #include "get_syscall_args.c"