From patchwork Sun May 17 20:49:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 473222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 49D911402B5 for ; Mon, 18 May 2015 06:49:33 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6318E8C08E; Sun, 17 May 2015 20:49:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DSeLHbuUG3LP; Sun, 17 May 2015 20:49:30 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id AC3E68C054; Sun, 17 May 2015 20:49:30 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 85B5C1BFC00 for ; Sun, 17 May 2015 20:49:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 82DB785DBC for ; Sun, 17 May 2015 20:49:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9W8rqP9__0dk for ; Sun, 17 May 2015 20:49:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from fudo.makrotopia.org (fudo.makrotopia.org [5.135.190.93]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 4396685CC7 for ; Sun, 17 May 2015 20:49:28 +0000 (UTC) Received: from local by fudo.makrotopia.org with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1Yu5Uz-0007Wg-C7 for uclibc@uclibc.org; Sun, 17 May 2015 22:49:26 +0200 Date: Sun, 17 May 2015 22:49:23 +0200 From: Daniel Golle To: uclibc@uclibc.org Subject: [PATCH] siginfo: add signal info for seccomp related SIGSYS Message-ID: <20150517204857.GA2615@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" uClibc doesn't define signal info for the SIGSYS signal which is issued in case of hitting a syscall prohibited by seccomp. This is sad as it makes debugging seccomp filter policies impossible on some architectures (at least ARM and PowerPC, maybe also others) which do not coincidentally set si_value.sival_int as the syscall number. To fix this, import the definitions and macros needed from glibc. Signed-off-by: Daniel Golle --- Patch was also submitted to openwrt-devel, see http://patchwork.ozlabs.org/patch/473215/ --- libc/sysdeps/linux/alpha/bits/siginfo.h | 11 +++++++++++ libc/sysdeps/linux/common/bits/siginfo.h | 11 +++++++++++ libc/sysdeps/linux/ia64/bits/siginfo.h | 11 +++++++++++ libc/sysdeps/linux/mips/bits/siginfo.h | 11 +++++++++++ libc/sysdeps/linux/sparc/bits/siginfo.h | 11 +++++++++++ 5 files changed, 55 insertions(+) diff --git a/libc/sysdeps/linux/alpha/bits/siginfo.h b/libc/sysdeps/linux/alpha/bits/siginfo.h index 0a37ad0..7e476aa 100644 --- a/libc/sysdeps/linux/alpha/bits/siginfo.h +++ b/libc/sysdeps/linux/alpha/bits/siginfo.h @@ -97,6 +97,14 @@ typedef struct siginfo int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t; @@ -115,6 +123,9 @@ typedef struct siginfo # define si_addr _sifields._sigfault.si_addr # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch /* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libc/sysdeps/linux/common/bits/siginfo.h b/libc/sysdeps/linux/common/bits/siginfo.h index c26e066..724f756 100644 --- a/libc/sysdeps/linux/common/bits/siginfo.h +++ b/libc/sysdeps/linux/common/bits/siginfo.h @@ -103,6 +103,14 @@ typedef struct siginfo long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t; @@ -121,6 +129,9 @@ typedef struct siginfo # define si_addr _sifields._sigfault.si_addr # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch /* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libc/sysdeps/linux/ia64/bits/siginfo.h b/libc/sysdeps/linux/ia64/bits/siginfo.h index 3ac988b..df18b36 100644 --- a/libc/sysdeps/linux/ia64/bits/siginfo.h +++ b/libc/sysdeps/linux/ia64/bits/siginfo.h @@ -102,6 +102,14 @@ typedef struct siginfo long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t; @@ -120,6 +128,9 @@ typedef struct siginfo # define si_addr _sifields._sigfault.si_addr # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch # ifdef __USE_GNU # define si_imm _sifields._sigfault._si_imm diff --git a/libc/sysdeps/linux/mips/bits/siginfo.h b/libc/sysdeps/linux/mips/bits/siginfo.h index 5199d4d..b204301 100644 --- a/libc/sysdeps/linux/mips/bits/siginfo.h +++ b/libc/sysdeps/linux/mips/bits/siginfo.h @@ -108,6 +108,14 @@ typedef struct siginfo long int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t; @@ -127,6 +135,9 @@ typedef struct siginfo # define si_addr_lsb _sifields._sigfault.si_addr_lsb # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch /* Values for `si_code'. Positive values are reserved for kernel-generated diff --git a/libc/sysdeps/linux/sparc/bits/siginfo.h b/libc/sysdeps/linux/sparc/bits/siginfo.h index 3ffeb6d..da1c838 100644 --- a/libc/sysdeps/linux/sparc/bits/siginfo.h +++ b/libc/sysdeps/linux/sparc/bits/siginfo.h @@ -104,6 +104,14 @@ typedef struct siginfo int si_band; /* Band event for SIGPOLL. */ int si_fd; } _sigpoll; + + /* SIGSYS. */ + struct + { + void *_call_addr; /* Calling user insn. */ + int _syscall; /* Triggering system call number. */ + unsigned int _arch; /* AUDIT_ARCH_* of syscall. */ + } _sigsys; } _sifields; } siginfo_t; @@ -123,6 +131,9 @@ typedef struct siginfo # define si_trapno _sifields._sigfault.si_trapno # define si_band _sifields._sigpoll.si_band # define si_fd _sifields._sigpoll.si_fd +# define si_call_addr _sifields._sigsys._call_addr +# define si_syscall _sifields._sigsys._syscall +# define si_arch _sifields._sigsys._arch /* Values for `si_code'. Positive values are reserved for kernel-generated