From c3948327717c29b10b5e00a436dc138b4ab1a486 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 5 Feb 2015 16:15:46 +0000 Subject: [PATCH] x86_64: do not interpet syscall number -1 as a x32 personality syscall 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 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/syscall.c b/syscall.c index dfeef77c..7f52cc8e 100644 --- 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 -- 2.40.0