From 08e2fd253a6c285b39c9ad86fe2a3685462f5c8e Mon Sep 17 00:00:00 2001 From: Eugene Syromiatnikov Date: Mon, 25 Dec 2017 23:45:04 +0100 Subject: [PATCH] Change the first argument of upoke from pid to tcp Users were updated automatically by: for i in `git grep -l 'upoke(tcp->pid'`; do \ sed -i 's/upoke(tcp->pid/upoke(tcp/g' "$i"; \ done * upoke.c (upoke): Change the first argument from pid_t pid to struct tcb *tcp. Use tcp->pid instead of pid in the function's body. * defs.h (upoke): Update declaration. * linux/alpha/set_error.c (arch_set_error, arch_set_success): Provide tcp in the first argument of the upoke call instead of tcp->pid. * linux/alpha/set_scno.c (arch_set_scno): Likewise. * linux/bfin/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/bfin/set_scno.c (arch_set_scno): Likewise. * linux/crisv10/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/crisv10/set_scno.c (arch_set_scno): Likewise. * linux/hppa/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/hppa/set_scno.c (arch_set_scno): Likewise. * linux/i386/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/i386/set_scno.c (arch_set_scno): Likewise. * linux/microblaze/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/microblaze/set_scno.c (arch_set_scno): Likewise. * linux/powerpc/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/powerpc/set_scno.c (arch_set_scno): Likewise. * linux/sh/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/sh/set_scno.c (arch_set_scno): Likewise. * linux/sh64/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/sh64/set_scno.c (arch_set_scno): Likewise. * linux/x86_64/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/x86_64/set_scno.c (arch_set_scno): Likewise. * linux/xtensa/set_error.c (arch_set_error, arch_set_success): Likewise. * linux/xtensa/set_scno.c (arch_set_scno): Likewise. --- defs.h | 2 +- linux/alpha/set_error.c | 6 +++--- linux/alpha/set_scno.c | 2 +- linux/bfin/set_error.c | 4 ++-- linux/bfin/set_scno.c | 2 +- linux/crisv10/set_error.c | 4 ++-- linux/crisv10/set_scno.c | 2 +- linux/hppa/set_error.c | 4 ++-- linux/hppa/set_scno.c | 2 +- linux/i386/set_error.c | 4 ++-- linux/i386/set_scno.c | 2 +- linux/microblaze/set_error.c | 4 ++-- linux/microblaze/set_scno.c | 2 +- linux/powerpc/set_error.c | 6 +++--- linux/powerpc/set_scno.c | 2 +- linux/sh/set_error.c | 4 ++-- linux/sh/set_scno.c | 2 +- linux/sh64/set_error.c | 4 ++-- linux/sh64/set_scno.c | 2 +- linux/x86_64/set_error.c | 4 ++-- linux/x86_64/set_scno.c | 2 +- linux/xtensa/set_error.c | 4 ++-- linux/xtensa/set_scno.c | 2 +- upoke.c | 7 ++++--- 24 files changed, 40 insertions(+), 39 deletions(-) diff --git a/defs.h b/defs.h index 35761290..2708bd35 100644 --- a/defs.h +++ b/defs.h @@ -451,7 +451,7 @@ extern int umovestr(struct tcb *, kernel_ulong_t addr, unsigned int len, char *laddr); extern int upeek(int pid, unsigned long, kernel_ulong_t *); -extern int upoke(int pid, unsigned long, kernel_ulong_t); +extern int upoke(struct tcb *tcp, unsigned long, kernel_ulong_t); extern bool print_array(struct tcb *, diff --git a/linux/alpha/set_error.c b/linux/alpha/set_error.c index bcc5ff86..169277bc 100644 --- a/linux/alpha/set_error.c +++ b/linux/alpha/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { alpha_r0 = tcp->u_error; - return upoke(tcp->pid, REG_R0, alpha_r0); + return upoke(tcp, REG_R0, alpha_r0); } static int arch_set_success(struct tcb *tcp) { - return upoke(tcp->pid, REG_A3, (alpha_a3 = 0)) - || upoke(tcp->pid, REG_R0, (alpha_r0 = tcp->u_rval)); + return upoke(tcp, REG_A3, (alpha_a3 = 0)) + || upoke(tcp, REG_R0, (alpha_r0 = tcp->u_rval)); } diff --git a/linux/alpha/set_scno.c b/linux/alpha/set_scno.c index d5bcfb6d..e285c9ab 100644 --- a/linux/alpha/set_scno.c +++ b/linux/alpha/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, REG_R0, scno); + return upoke(tcp, REG_R0, scno); } diff --git a/linux/bfin/set_error.c b/linux/bfin/set_error.c index 2bfecda0..002d904d 100644 --- a/linux/bfin/set_error.c +++ b/linux/bfin/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { bfin_r0 = -tcp->u_error; - return upoke(tcp->pid, PT_R0, bfin_r0); + return upoke(tcp, PT_R0, bfin_r0); } static int arch_set_success(struct tcb *tcp) { bfin_r0 = tcp->u_rval; - return upoke(tcp->pid, PT_R0, bfin_r0); + return upoke(tcp, PT_R0, bfin_r0); } diff --git a/linux/bfin/set_scno.c b/linux/bfin/set_scno.c index 4508be1a..d63230fe 100644 --- a/linux/bfin/set_scno.c +++ b/linux/bfin/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, PT_ORIG_P0, scno); + return upoke(tcp, PT_ORIG_P0, scno); } diff --git a/linux/crisv10/set_error.c b/linux/crisv10/set_error.c index 3a14a87a..d6623b62 100644 --- a/linux/crisv10/set_error.c +++ b/linux/crisv10/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { cris_r10 = -tcp->u_error; - return upoke(tcp->pid, 4 * PT_R10, cris_r10); + return upoke(tcp, 4 * PT_R10, cris_r10); } static int arch_set_success(struct tcb *tcp) { cris_r10 = tcp->u_rval; - return upoke(tcp->pid, 4 * PT_R10, cris_r10); + return upoke(tcp, 4 * PT_R10, cris_r10); } diff --git a/linux/crisv10/set_scno.c b/linux/crisv10/set_scno.c index 0de38fa7..ec97d67e 100644 --- a/linux/crisv10/set_scno.c +++ b/linux/crisv10/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, 4 * PT_R9, scno); + return upoke(tcp, 4 * PT_R9, scno); } diff --git a/linux/hppa/set_error.c b/linux/hppa/set_error.c index 92a7979f..edaada7f 100644 --- a/linux/hppa/set_error.c +++ b/linux/hppa/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { hppa_r28 = -tcp->u_error; - return upoke(tcp->pid, PT_GR28, hppa_r28); + return upoke(tcp, PT_GR28, hppa_r28); } static int arch_set_success(struct tcb *tcp) { hppa_r28 = tcp->u_rval; - return upoke(tcp->pid, PT_GR28, hppa_r28); + return upoke(tcp, PT_GR28, hppa_r28); } diff --git a/linux/hppa/set_scno.c b/linux/hppa/set_scno.c index d4d873be..fcf8f43a 100644 --- a/linux/hppa/set_scno.c +++ b/linux/hppa/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, PT_GR20, scno); + return upoke(tcp, PT_GR20, scno); } diff --git a/linux/i386/set_error.c b/linux/i386/set_error.c index 92b0a8d7..7d47e28b 100644 --- a/linux/i386/set_error.c +++ b/linux/i386/set_error.c @@ -3,7 +3,7 @@ arch_set_error(struct tcb *tcp) { i386_regs.eax = -tcp->u_error; #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, 4 * EAX, i386_regs.eax); + return upoke(tcp, 4 * EAX, i386_regs.eax); #else return set_regs(tcp->pid); #endif @@ -14,7 +14,7 @@ arch_set_success(struct tcb *tcp) { i386_regs.eax = tcp->u_rval; #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, 4 * EAX, i386_regs.eax); + return upoke(tcp, 4 * EAX, i386_regs.eax); #else return set_regs(tcp->pid); #endif diff --git a/linux/i386/set_scno.c b/linux/i386/set_scno.c index 3abe7768..67736eae 100644 --- a/linux/i386/set_scno.c +++ b/linux/i386/set_scno.c @@ -2,7 +2,7 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, 4 * ORIG_EAX, scno); + return upoke(tcp, 4 * ORIG_EAX, scno); #else i386_regs.orig_eax = scno; return set_regs(tcp->pid); diff --git a/linux/microblaze/set_error.c b/linux/microblaze/set_error.c index 46866719..5bb83b5f 100644 --- a/linux/microblaze/set_error.c +++ b/linux/microblaze/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { microblaze_r3 = -tcp->u_error; - return upoke(tcp->pid, 3 * 4, microblaze_r3); + return upoke(tcp, 3 * 4, microblaze_r3); } static int arch_set_success(struct tcb *tcp) { microblaze_r3 = tcp->u_rval; - return upoke(tcp->pid, 3 * 4, microblaze_r3); + return upoke(tcp, 3 * 4, microblaze_r3); } diff --git a/linux/microblaze/set_scno.c b/linux/microblaze/set_scno.c index b9cddefc..4f69a525 100644 --- a/linux/microblaze/set_scno.c +++ b/linux/microblaze/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, 0, scno); + return upoke(tcp, 0, scno); } diff --git a/linux/powerpc/set_error.c b/linux/powerpc/set_error.c index 7edabee5..38ae32bb 100644 --- a/linux/powerpc/set_error.c +++ b/linux/powerpc/set_error.c @@ -3,7 +3,7 @@ arch_set_error(struct tcb *tcp) { ppc_regs.gpr[3] = tcp->u_error; #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]); + return upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]); #else return set_regs(tcp->pid); #endif @@ -15,8 +15,8 @@ arch_set_success(struct tcb *tcp) ppc_regs.gpr[3] = tcp->u_rval; ppc_regs.ccr &= ~0x10000000; #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, sizeof(long) * PT_CCR, ppc_regs.ccr) || - upoke(tcp->pid, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]); + return upoke(tcp, sizeof(long) * PT_CCR, ppc_regs.ccr) || + upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]); #else return set_regs(tcp->pid); #endif diff --git a/linux/powerpc/set_scno.c b/linux/powerpc/set_scno.c index c5a04687..b2f66934 100644 --- a/linux/powerpc/set_scno.c +++ b/linux/powerpc/set_scno.c @@ -2,7 +2,7 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, sizeof(long) * PT_R0, scno); + return upoke(tcp, sizeof(long) * PT_R0, scno); #else ppc_regs.gpr[0] = scno; return set_regs(tcp->pid); diff --git a/linux/sh/set_error.c b/linux/sh/set_error.c index cb093b64..bad76ede 100644 --- a/linux/sh/set_error.c +++ b/linux/sh/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { sh_r0 = -tcp->u_error; - return upoke(tcp->pid, 4 * REG_REG0, sh_r0); + return upoke(tcp, 4 * REG_REG0, sh_r0); } static int arch_set_success(struct tcb *tcp) { sh_r0 = tcp->u_rval; - return upoke(tcp->pid, 4 * REG_REG0, sh_r0); + return upoke(tcp, 4 * REG_REG0, sh_r0); } diff --git a/linux/sh/set_scno.c b/linux/sh/set_scno.c index 5f71664a..4c175ed7 100644 --- a/linux/sh/set_scno.c +++ b/linux/sh/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, 4 * (REG_REG0 + 3), scno); + return upoke(tcp, 4 * (REG_REG0 + 3), scno); } diff --git a/linux/sh64/set_error.c b/linux/sh64/set_error.c index 35271fb5..29293b22 100644 --- a/linux/sh64/set_error.c +++ b/linux/sh64/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { sh64_r9 = -tcp->u_error; - return upoke(tcp->pid, REG_GENERAL(9), sh64_r9); + return upoke(tcp, REG_GENERAL(9), sh64_r9); } static int arch_set_success(struct tcb *tcp) { sh64_r9 = tcp->u_rval; - return upoke(tcp->pid, REG_GENERAL(9), sh64_r9); + return upoke(tcp, REG_GENERAL(9), sh64_r9); } diff --git a/linux/sh64/set_scno.c b/linux/sh64/set_scno.c index be4f1ed1..0e7c18fa 100644 --- a/linux/sh64/set_scno.c +++ b/linux/sh64/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, REG_SYSCALL, scno); + return upoke(tcp, REG_SYSCALL, scno); } diff --git a/linux/x86_64/set_error.c b/linux/x86_64/set_error.c index 6c31bd86..04272cde 100644 --- a/linux/x86_64/set_error.c +++ b/linux/x86_64/set_error.c @@ -11,7 +11,7 @@ arch_set_error(struct tcb *tcp) { #ifdef HAVE_GETREGS_OLD x86_64_regs.rax = -(long long) tcp->u_error; - return upoke(tcp->pid, 8 * RAX, x86_64_regs.rax); + return upoke(tcp, 8 * RAX, x86_64_regs.rax); #else if (x86_io.iov_len == sizeof(i386_regs)) return i386_set_error(tcp); @@ -26,7 +26,7 @@ arch_set_success(struct tcb *tcp) { #ifdef HAVE_GETREGS_OLD x86_64_regs.rax = (long long) tcp->u_rval; - return upoke(tcp->pid, 8 * RAX, x86_64_regs.rax); + return upoke(tcp, 8 * RAX, x86_64_regs.rax); #else if (x86_io.iov_len == sizeof(i386_regs)) return i386_set_success(tcp); diff --git a/linux/x86_64/set_scno.c b/linux/x86_64/set_scno.c index 6438c526..3ca402eb 100644 --- a/linux/x86_64/set_scno.c +++ b/linux/x86_64/set_scno.c @@ -8,7 +8,7 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { #ifdef HAVE_GETREGS_OLD - return upoke(tcp->pid, 8 * ORIG_RAX, scno); + return upoke(tcp, 8 * ORIG_RAX, scno); #else if (x86_io.iov_len == sizeof(i386_regs)) return i386_set_scno(tcp, scno); diff --git a/linux/xtensa/set_error.c b/linux/xtensa/set_error.c index 4eb59171..e786b8cc 100644 --- a/linux/xtensa/set_error.c +++ b/linux/xtensa/set_error.c @@ -2,12 +2,12 @@ static int arch_set_error(struct tcb *tcp) { xtensa_a2 = -tcp->u_error; - return upoke(tcp->pid, REG_A_BASE + 2, xtensa_a2); + return upoke(tcp, REG_A_BASE + 2, xtensa_a2); } static int arch_set_success(struct tcb *tcp) { xtensa_a2 = tcp->u_rval; - return upoke(tcp->pid, REG_A_BASE + 2, xtensa_a2); + return upoke(tcp, REG_A_BASE + 2, xtensa_a2); } diff --git a/linux/xtensa/set_scno.c b/linux/xtensa/set_scno.c index 54c948d3..ca442fc3 100644 --- a/linux/xtensa/set_scno.c +++ b/linux/xtensa/set_scno.c @@ -1,5 +1,5 @@ static int arch_set_scno(struct tcb *tcp, kernel_ulong_t scno) { - return upoke(tcp->pid, SYSCALL_NR, scno); + return upoke(tcp, SYSCALL_NR, scno); } diff --git a/upoke.c b/upoke.c index dda0b8d7..2ea20c5d 100644 --- a/upoke.c +++ b/upoke.c @@ -29,11 +29,12 @@ #include "ptrace.h" int -upoke(int pid, unsigned long off, kernel_ulong_t val) +upoke(struct tcb *tcp, unsigned long off, kernel_ulong_t val) { - if (ptrace(PTRACE_POKEUSER, pid, off, val)) { + if (ptrace(PTRACE_POKEUSER, tcp->pid, off, val)) { if (errno != ESRCH) - perror_msg("upoke: PTRACE_POKEUSER pid:%d @%#lx)", pid, off); + perror_msg("upoke: PTRACE_POKEUSER pid:%d @%#lx)", + tcp->pid, off); return -1; } return 0;