From eb9db583624bd69853ada4276c32bead1b4a5ece Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Thu, 8 Feb 2018 11:40:01 +0100 Subject: [PATCH] linux/x86_64/set_error.c: update eax for compat personality Since this is where get_error gets the return value from in the compat case. linux/x86_64/set_error.c (set_error, set_success): Update i386_regs.eax if tracee is in compat personality. --- linux/x86_64/set_error.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/linux/x86_64/set_error.c b/linux/x86_64/set_error.c index 04272cde..0c7e188c 100644 --- a/linux/x86_64/set_error.c +++ b/linux/x86_64/set_error.c @@ -10,13 +10,19 @@ static int arch_set_error(struct tcb *tcp) { #ifdef HAVE_GETREGS_OLD - x86_64_regs.rax = -(long long) tcp->u_error; - return upoke(tcp, 8 * RAX, x86_64_regs.rax); + kernel_ulong_t rval = -(kernel_long_t) tcp->u_error; + + if (x86_io.iov_len == sizeof(i386_regs)) + i386_regs.eax = rval; + else + x86_64_regs.rax = rval; + + return upoke(tcp, 8 * RAX, rval); #else if (x86_io.iov_len == sizeof(i386_regs)) return i386_set_error(tcp); - x86_64_regs.rax = -(long long) tcp->u_error; + x86_64_regs.rax = -(kernel_long_t) tcp->u_error; return set_regs(tcp->pid); #endif } @@ -25,13 +31,19 @@ static int arch_set_success(struct tcb *tcp) { #ifdef HAVE_GETREGS_OLD - x86_64_regs.rax = (long long) tcp->u_rval; - return upoke(tcp, 8 * RAX, x86_64_regs.rax); + kernel_ulong_t rval = (kernel_ulong_t) tcp->u_rval; + + if (x86_io.iov_len == sizeof(i386_regs)) + i386_regs.eax = rval; + else + x86_64_regs.rax = rval; + + return upoke(tcp, 8 * RAX, rval); #else if (x86_io.iov_len == sizeof(i386_regs)) return i386_set_success(tcp); - x86_64_regs.rax = (long long) tcp->u_rval; + x86_64_regs.rax = (kernel_ulong_t) tcp->u_rval; return set_regs(tcp->pid); #endif } -- 2.40.0