]> granicus.if.org Git - strace/commitdiff
x86_64: do not interpet syscall number -1 as a x32 personality syscall
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 5 Feb 2015 16:15:46 +0000 (16:15 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 6 Feb 2015 01:22:28 +0000 (01:22 +0000)
Syscall number -1 might be a side effect of SECCOMP_RET_ERRNO filtering.

* syscall.c (get_scno) [X86_64]: Handle the case of scno == -1.

syscall.c

index dfeef77cb6bcadc544acea14cc7bb0188c75a018..7f52cc8eaeb319ebeac8ddac6b6828ca529184a7 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -1264,8 +1264,22 @@ get_scno(struct tcb *tcp)
                scno = x86_64_regs.orig_rax;
                currpers = 0;
                if (scno & __X32_SYSCALL_BIT) {
-                       scno -= __X32_SYSCALL_BIT;
-                       currpers = 2;
+                       /*
+                        * Syscall number -1 requires special treatment:
+                        * it might be a side effect of SECCOMP_RET_ERRNO
+                        * filtering that sets orig_rax to -1
+                        * in some versions of linux kernel.
+                        * If that is the case, then
+                        * __X32_SYSCALL_BIT logic does not apply.
+                        */
+                       if ((long long) x86_64_regs.orig_rax != -1) {
+                               scno -= __X32_SYSCALL_BIT;
+                               currpers = 2;
+                       } else {
+#  ifdef X32
+                               currpers = 2;
+#  endif
+                       }
                }
        }
 # elif 0