]> granicus.if.org Git - strace/commitdiff
linux/x86_64/set_error.c: update eax for compat personality
authorEugene Syromyatnikov <evgsyr@gmail.com>
Thu, 8 Feb 2018 10:40:01 +0000 (11:40 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 9 Feb 2018 15:40:50 +0000 (15:40 +0000)
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

index 04272cde54c14b752251c942bbdb460536ca547d..0c7e188c5173e731cb876262bfcfedc18a2f7285 100644 (file)
@@ -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
 }