Signed-off-by: Paul Moore <***@redhat.com>
---
include/seccomp.h.in | 2
src/Makefile.am | 3
src/arch-mips64n32-syscalls.c | 493 +++++++++++++++++++++++++++++++++++++++++
src/arch-mips64n32.c | 42 +++
src/arch-mips64n32.h | 44 ++++
src/arch-syscall-check.c | 30 ++
src/arch-syscall-dump.c | 5
src/arch-syscall-validate | 39 +++
src/arch.c | 30 ++
src/gen_pfc.c | 4
10 files changed, 682 insertions(+), 10 deletions(-)
create mode 100644 src/arch-mips64n32-syscalls.c
create mode 100644 src/arch-mips64n32.c
create mode 100644 src/arch-mips64n32.h
diff --git a/include/seccomp.h.in b/include/seccomp.h.in
index 15c147e..7007b37 100644
--- a/include/seccomp.h.in
+++ b/include/seccomp.h.in
@@ -126,8 +126,10 @@ struct scmp_arg_cmp {
*/
#define SCMP_ARCH_MIPS AUDIT_ARCH_MIPS
#define SCMP_ARCH_MIPS64 AUDIT_ARCH_MIPS64
+#define SCMP_ARCH_MIPS64N32 AUDIT_ARCH_MIPS64N32
#define SCMP_ARCH_MIPSEL AUDIT_ARCH_MIPSEL
#define SCMP_ARCH_MIPSEL64 AUDIT_ARCH_MIPSEL64
+#define SCMP_ARCH_MIPSEL64N32 AUDIT_ARCH_MIPSEL64N32
/**
* Convert a syscall name into the associated syscall number
diff --git a/src/Makefile.am b/src/Makefile.am
index 5b737fd..271a562 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,7 +28,8 @@ SOURCES_ARCH = \
arch-x32.h arch-x32.c arch-x32-syscalls.c \
arch-arm.h arch-arm.c arch-arm-syscalls.c \
arch-mips.h arch-mips.c arch-mips-syscalls.c \
- arch-mips64.h arch-mips64.c arch-mips64-syscalls.c
+ arch-mips64.h arch-mips64.c arch-mips64-syscalls.c \
+ arch-mips64n32.h arch-mips64n32.c arch-mips64n32-syscalls.c
SOURCES_GEN = \
api.c system.h \
diff --git a/src/arch-mips64n32-syscalls.c b/src/arch-mips64n32-syscalls.c
new file mode 100644
index 0000000..dfba051
--- /dev/null
+++ b/src/arch-mips64n32-syscalls.c
@@ -0,0 +1,493 @@
+/**
+ * Enhanced Seccomp MIPS Specific Code
+ *
+ * Copyright (c) 2014 Red Hat <***@redhat.com>
+ * Author: Paul Moore <***@redhat.com>
+ *
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <string.h>
+
+#include <seccomp.h>
+
+#include "arch.h"
+#include "arch-mips64n32.h"
+
+/* N32 ABI */
+#define __NR_SYSCALL_BASE 6000
+
+/* NOTE: based on Linux 3.16-rc7+ */
+const struct arch_syscall_def mips64n32_syscall_table[] = { \
+ { "_llseek", __PNR__llseek },
+ { "_newselect", (__NR_SYSCALL_BASE + 22) },
+ { "_sysctl", (__NR_SYSCALL_BASE + 152) },
+ { "accept", (__NR_SYSCALL_BASE + 42) },
+ { "accept4", (__NR_SYSCALL_BASE + 297) },
+ { "access", (__NR_SYSCALL_BASE + 20) },
+ { "acct", (__NR_SYSCALL_BASE + 158) },
+ { "add_key", (__NR_SYSCALL_BASE + 243) },
+ { "adjtimex", (__NR_SYSCALL_BASE + 154) },
+ { "afs_syscall", (__NR_SYSCALL_BASE + 176) },
+ { "alarm", (__NR_SYSCALL_BASE + 37) },
+ { "arm_fadvise64_64", __PNR_arm_fadvise64_64 },
+ { "arm_sync_file_range", __PNR_arm_sync_file_range },
+ { "arch_prctl", __PNR_arch_prctl },
+ { "bdflush", __PNR_bdflush },
+ { "bind", (__NR_SYSCALL_BASE + 48) },
+ { "break", __PNR_break },
+ { "brk", (__NR_SYSCALL_BASE + 12) },
+ { "cachectl", (__NR_SYSCALL_BASE + 198) },
+ { "cacheflush", (__NR_SYSCALL_BASE + 197) },
+ { "capget", (__NR_SYSCALL_BASE + 123) },
+ { "capset", (__NR_SYSCALL_BASE + 124) },
+ { "chdir", (__NR_SYSCALL_BASE + 78) },
+ { "chmod", (__NR_SYSCALL_BASE + 88) },
+ { "chown", (__NR_SYSCALL_BASE + 90) },
+ { "chown32", __PNR_chown32 },
+ { "chroot", (__NR_SYSCALL_BASE + 156) },
+ { "clock_adjtime", (__NR_SYSCALL_BASE + 305) },
+ { "clock_getres", (__NR_SYSCALL_BASE + 227) },
+ { "clock_gettime", (__NR_SYSCALL_BASE + 226) },
+ { "clock_nanosleep", (__NR_SYSCALL_BASE + 228) },
+ { "clock_settime", (__NR_SYSCALL_BASE + 225) },
+ { "clone", (__NR_SYSCALL_BASE + 55) },
+ { "close", (__NR_SYSCALL_BASE + 3) },
+ { "connect", (__NR_SYSCALL_BASE + 41) },
+ { "creat", (__NR_SYSCALL_BASE + 83) },
+ { "create_module", (__NR_SYSCALL_BASE + 167) },
+ { "delete_module", (__NR_SYSCALL_BASE + 169) },
+ { "dup", (__NR_SYSCALL_BASE + 31) },
+ { "dup2", (__NR_SYSCALL_BASE + 32) },
+ { "dup3", (__NR_SYSCALL_BASE + 290) },
+ { "epoll_create", (__NR_SYSCALL_BASE + 207) },
+ { "epoll_create1", (__NR_SYSCALL_BASE + 289) },
+ { "epoll_ctl", (__NR_SYSCALL_BASE + 208) },
+ { "epoll_ctl_old", __PNR_epoll_ctl_old },
+ { "epoll_pwait", (__NR_SYSCALL_BASE + 276) },
+ { "epoll_wait", (__NR_SYSCALL_BASE + 209) },
+ { "epoll_wait_old", __PNR_epoll_wait_old },
+ { "eventfd", (__NR_SYSCALL_BASE + 282) },
+ { "eventfd2", (__NR_SYSCALL_BASE + 288) },
+ { "execve", (__NR_SYSCALL_BASE + 57) },
+ { "exit", (__NR_SYSCALL_BASE + 58) },
+ { "exit_group", (__NR_SYSCALL_BASE + 205) },
+ { "faccessat", (__NR_SYSCALL_BASE + 263) },
+ { "fadvise64", (__NR_SYSCALL_BASE + 216) },
+ { "fadvise64_64", __PNR_fadvise64_64 },
+ { "fallocate", (__NR_SYSCALL_BASE + 283) },
+ { "fanotify_init", (__NR_SYSCALL_BASE + 300) },
+ { "fanotify_mark", (__NR_SYSCALL_BASE + 301) },
+ { "fchdir", (__NR_SYSCALL_BASE + 79) },
+ { "fchmod", (__NR_SYSCALL_BASE + 89) },
+ { "fchmodat", (__NR_SYSCALL_BASE + 262) },
+ { "fchown", (__NR_SYSCALL_BASE + 91) },
+ { "fchown32", __PNR_fchown32 },
+ { "fchownat", (__NR_SYSCALL_BASE + 254) },
+ { "fcntl", (__NR_SYSCALL_BASE + 70) },
+ { "fcntl64", (__NR_SYSCALL_BASE + 212) },
+ { "fdatasync", (__NR_SYSCALL_BASE + 73) },
+ { "fgetxattr", (__NR_SYSCALL_BASE + 185) },
+ { "finit_module", (__NR_SYSCALL_BASE + 312) },
+ { "flistxattr", (__NR_SYSCALL_BASE + 188) },
+ { "flock", (__NR_SYSCALL_BASE + 71) },
+ { "fork", (__NR_SYSCALL_BASE + 56) },
+ { "fremovexattr", (__NR_SYSCALL_BASE + 191) },
+ { "fsetxattr", (__NR_SYSCALL_BASE + 182) },
+ { "fstat", (__NR_SYSCALL_BASE + 5) },
+ { "fstat64", __PNR_fstat64 },
+ { "fstatat64", __PNR_fstat64 },
+ { "fstatfs", (__NR_SYSCALL_BASE + 135) },
+ { "fstatfs64", (__NR_SYSCALL_BASE + 218) },
+ { "fsync", (__NR_SYSCALL_BASE + 72) },
+ { "ftime", __PNR_ftime },
+ { "ftruncate", (__NR_SYSCALL_BASE + 75) },
+ { "ftruncate64", __PNR_ftruncate64 },
+ { "futex", (__NR_SYSCALL_BASE + 194) },
+ { "futimesat", (__NR_SYSCALL_BASE + 255) },
+ { "get_kernel_syms", (__NR_SYSCALL_BASE + 170) },
+ { "get_mempolicy", (__NR_SYSCALL_BASE + 232) },
+ { "get_robust_list", (__NR_SYSCALL_BASE + 273) },
+ { "get_thread_area", __PNR_get_thread_area },
+ { "getcpu", (__NR_SYSCALL_BASE + 275) },
+ { "getcwd", (__NR_SYSCALL_BASE + 77) },
+ { "getdents", (__NR_SYSCALL_BASE + 76) },
+ { "getdents64", (__NR_SYSCALL_BASE + 299) },
+ { "getegid", (__NR_SYSCALL_BASE + 106) },
+ { "getegid32", __PNR_getegid32 },
+ { "geteuid", (__NR_SYSCALL_BASE + 105) },
+ { "geteuid32", __PNR_geteuid32 },
+ { "getgid", (__NR_SYSCALL_BASE + 102) },
+ { "getgid32", __PNR_getgid32 },
+ { "getgroups", (__NR_SYSCALL_BASE + 113) },
+ { "getgroups32", __PNR_getgroups32 },
+ { "getitimer", (__NR_SYSCALL_BASE + 35) },
+ { "getpeername", (__NR_SYSCALL_BASE + 51) },
+ { "getpgid", (__NR_SYSCALL_BASE + 119) },
+ { "getpgrp", (__NR_SYSCALL_BASE + 109) },
+ { "getpid", (__NR_SYSCALL_BASE + 38) },
+ { "getpmsg", (__NR_SYSCALL_BASE + 174) },
+ { "getppid", (__NR_SYSCALL_BASE + 108) },
+ { "getpriority", (__NR_SYSCALL_BASE + 137) },
+ { "getresgid", (__NR_SYSCALL_BASE + 118) },
+ { "getresgid32", __PNR_getresgid32 },
+ { "getresuid", (__NR_SYSCALL_BASE + 116) },
+ { "getresuid32", __PNR_getresuid32 },
+ { "getrlimit", (__NR_SYSCALL_BASE + 95) },
+ { "getrusage", (__NR_SYSCALL_BASE + 96) },
+ { "getsid", (__NR_SYSCALL_BASE + 122) },
+ { "getsockname", (__NR_SYSCALL_BASE + 50) },
+ { "getsockopt", (__NR_SYSCALL_BASE + 54) },
+ { "gettid", (__NR_SYSCALL_BASE + 178) },
+ { "gettimeofday", (__NR_SYSCALL_BASE + 94) },
+ { "getuid", (__NR_SYSCALL_BASE + 100) },
+ { "getuid32", __PNR_getuid32 },
+ { "getxattr", (__NR_SYSCALL_BASE + 183) },
+ { "gtty", __PNR_gtty },
+ { "idle", __PNR_idle },
+ { "init_module", (__NR_SYSCALL_BASE + 168) },
+ { "inotify_add_watch", (__NR_SYSCALL_BASE + 248) },
+ { "inotify_init", (__NR_SYSCALL_BASE + 247) },
+ { "inotify_init1", (__NR_SYSCALL_BASE + 292) },
+ { "inotify_rm_watch", (__NR_SYSCALL_BASE + 249) },
+ { "io_cancel", (__NR_SYSCALL_BASE + 204) },
+ { "io_destroy", (__NR_SYSCALL_BASE + 201) },
+ { "io_getevents", (__NR_SYSCALL_BASE + 202) },
+ { "io_setup", (__NR_SYSCALL_BASE + 200) },
+ { "io_submit", (__NR_SYSCALL_BASE + 203) },
+ { "ioctl", (__NR_SYSCALL_BASE + 15) },
+ { "ioperm", __PNR_ioperm },
+ { "iopl", __PNR_iopl },
+ { "ioprio_get", (__NR_SYSCALL_BASE + 278) },
+ { "ioprio_set", (__NR_SYSCALL_BASE + 277) },
+ { "ipc", __PNR_ipc },
+ { "kcmp", (__NR_SYSCALL_BASE + 311) },
+ { "kexec_load", (__NR_SYSCALL_BASE + 274) },
+ { "keyctl", (__NR_SYSCALL_BASE + 245) },
+ { "kill", (__NR_SYSCALL_BASE + 60) },
+ { "lchown", (__NR_SYSCALL_BASE + 92) },
+ { "lchown32", __PNR_lchown32 },
+ { "lgetxattr", (__NR_SYSCALL_BASE + 184) },
+ { "link", (__NR_SYSCALL_BASE + 84) },
+ { "linkat", (__NR_SYSCALL_BASE + 259) },
+ { "listen", (__NR_SYSCALL_BASE + 49) },
+ { "listxattr", (__NR_SYSCALL_BASE + 186) },
+ { "llistxattr", (__NR_SYSCALL_BASE + 187) },
+ { "lock", __PNR_lock },
+ { "lookup_dcookie", (__NR_SYSCALL_BASE + 206) },
+ { "lremovexattr", (__NR_SYSCALL_BASE + 190) },
+ { "lseek", (__NR_SYSCALL_BASE + 8) },
+ { "lsetxattr", (__NR_SYSCALL_BASE + 181) },
+ { "lstat", (__NR_SYSCALL_BASE + 6) },
+ { "lstat64", __PNR_lstat64 },
+ { "madvise", (__NR_SYSCALL_BASE + 27) },
+ { "mbind", (__NR_SYSCALL_BASE + 231) },
+ { "migrate_pages", (__NR_SYSCALL_BASE + 250) },
+ { "mincore", (__NR_SYSCALL_BASE + 26) },
+ { "mkdir", (__NR_SYSCALL_BASE + 81) },
+ { "mkdirat", (__NR_SYSCALL_BASE + 252) },
+ { "mknod", (__NR_SYSCALL_BASE + 131) },
+ { "mknodat", (__NR_SYSCALL_BASE + 253) },
+ { "mlock", (__NR_SYSCALL_BASE + 146) },
+ { "mlockall", (__NR_SYSCALL_BASE + 148) },
+ { "mmap", (__NR_SYSCALL_BASE + 9) },
+ { "mmap2", __PNR_mmap2 },
+ { "modify_ldt", __PNR_modify_ldt },
+ { "mount", (__NR_SYSCALL_BASE + 160) },
+ { "move_pages", (__NR_SYSCALL_BASE + 271) },
+ { "mprotect", (__NR_SYSCALL_BASE + 10) },
+ { "mpx", __PNR_mpx },
+ { "mq_getsetattr", (__NR_SYSCALL_BASE + 239) },
+ { "mq_notify", (__NR_SYSCALL_BASE + 238) },
+ { "mq_open", (__NR_SYSCALL_BASE + 234) },
+ { "mq_timedreceive", (__NR_SYSCALL_BASE + 237) },
+ { "mq_timedsend", (__NR_SYSCALL_BASE + 236) },
+ { "mq_unlink", (__NR_SYSCALL_BASE + 235) },
+ { "mremap", (__NR_SYSCALL_BASE + 24) },
+ { "msgctl", (__NR_SYSCALL_BASE + 69) },
+ { "msgget", (__NR_SYSCALL_BASE + 66) },
+ { "msgrcv", (__NR_SYSCALL_BASE + 68) },
+ { "msgsnd", (__NR_SYSCALL_BASE + 67) },
+ { "msync", (__NR_SYSCALL_BASE + 25) },
+ { "munlock", (__NR_SYSCALL_BASE + 147) },
+ { "munlockall", (__NR_SYSCALL_BASE + 149) },
+ { "munmap", (__NR_SYSCALL_BASE + 11) },
+ { "name_to_handle_at", (__NR_SYSCALL_BASE + 303) },
+ { "nanosleep", (__NR_SYSCALL_BASE + 34) },
+ { "newfstatat", (__NR_SYSCALL_BASE + 256) },
+ { "nfsservctl", (__NR_SYSCALL_BASE + 173) },
+ { "nice", __PNR_nice },
+ { "oldfstat", __PNR_oldfstat },
+ { "oldlstat", __PNR_oldlstat },
+ { "oldolduname", __PNR_oldolduname },
+ { "oldstat", __PNR_oldstat },
+ { "olduname", __PNR_olduname },
+ { "open", (__NR_SYSCALL_BASE + 2) },
+ { "open_by_handle_at", (__NR_SYSCALL_BASE + 304) },
+ { "openat", (__NR_SYSCALL_BASE + 251) },
+ { "pause", (__NR_SYSCALL_BASE + 33) },
+ { "pciconfig_iobase", __PNR_pciconfig_iobase },
+ { "pciconfig_read", __PNR_pciconfig_read },
+ { "pciconfig_write", __PNR_pciconfig_write },
+ { "perf_event_open", (__NR_SYSCALL_BASE + 296) },
+ { "personality", (__NR_SYSCALL_BASE + 132) },
+ { "pipe", (__NR_SYSCALL_BASE + 21) },
+ { "pipe2", (__NR_SYSCALL_BASE + 291) },
+ { "pivot_root", (__NR_SYSCALL_BASE + 151) },
+ { "poll", (__NR_SYSCALL_BASE + 7) },
+ { "ppoll", (__NR_SYSCALL_BASE + 265) },
+ { "prctl", (__NR_SYSCALL_BASE + 153) },
+ { "pread64", (__NR_SYSCALL_BASE + 16) },
+ { "preadv", (__NR_SYSCALL_BASE + 293) },
+ { "prlimit64", (__NR_SYSCALL_BASE + 302) },
+ { "process_vm_readv", (__NR_SYSCALL_BASE + 309) },
+ { "process_vm_writev", (__NR_SYSCALL_BASE + 310) },
+ { "prof", __PNR_prof },
+ { "profil", __PNR_profil },
+ { "pselect6", (__NR_SYSCALL_BASE + 264) },
+ { "ptrace", (__NR_SYSCALL_BASE + 99) },
+ { "putpmsg", (__NR_SYSCALL_BASE + 175) },
+ { "pwrite64", (__NR_SYSCALL_BASE + 17) },
+ { "pwritev", (__NR_SYSCALL_BASE + 294) },
+ { "query_module", (__NR_SYSCALL_BASE + 171) },
+ { "quotactl", (__NR_SYSCALL_BASE + 172) },
+ { "read", (__NR_SYSCALL_BASE + 0) },
+ { "readahead", (__NR_SYSCALL_BASE + 179) },
+ { "readdir", __PNR_readdir },
+ { "readlink", (__NR_SYSCALL_BASE + 87) },
+ { "readlinkat", (__NR_SYSCALL_BASE + 261) },
+ { "readv", (__NR_SYSCALL_BASE + 18) },
+ { "reboot", (__NR_SYSCALL_BASE + 164) },
+ { "recv", __PNR_recv },
+ { "recvfrom", (__NR_SYSCALL_BASE + 44) },
+ { "recvmmsg", (__NR_SYSCALL_BASE + 298) },
+ { "recvmsg", (__NR_SYSCALL_BASE + 46) },
+ { "remap_file_pages", (__NR_SYSCALL_BASE + 210) },
+ { "removexattr", (__NR_SYSCALL_BASE + 189) },
+ { "rename", (__NR_SYSCALL_BASE + 80) },
+ { "renameat", (__NR_SYSCALL_BASE + 258) },
+ { "renameat2", (__NR_SYSCALL_BASE + 315) },
+ { "request_key", (__NR_SYSCALL_BASE + 244) },
+ { "restart_syscall", (__NR_SYSCALL_BASE + 214) },
+ { "rmdir", (__NR_SYSCALL_BASE + 82) },
+ { "rt_sigaction", (__NR_SYSCALL_BASE + 13) },
+ { "rt_sigpending", (__NR_SYSCALL_BASE + 125) },
+ { "rt_sigprocmask", (__NR_SYSCALL_BASE + 14) },
+ { "rt_sigqueueinfo", (__NR_SYSCALL_BASE + 127) },
+ { "rt_sigreturn", (__NR_SYSCALL_BASE + 211) },
+ { "rt_sigsuspend", (__NR_SYSCALL_BASE + 128) },
+ { "rt_sigtimedwait", (__NR_SYSCALL_BASE + 126) },
+ { "rt_tgsigqueueinfo", (__NR_SYSCALL_BASE + 295) },
+ { "sched_get_priority_max", (__NR_SYSCALL_BASE + 143) },
+ { "sched_get_priority_min", (__NR_SYSCALL_BASE + 144) },
+ { "sched_getaffinity", (__NR_SYSCALL_BASE + 196) },
+ { "sched_getattr", (__NR_SYSCALL_BASE + 314) },
+ { "sched_getparam", (__NR_SYSCALL_BASE + 140) },
+ { "sched_getscheduler", (__NR_SYSCALL_BASE + 142) },
+ { "sched_rr_get_interval", (__NR_SYSCALL_BASE + 145) },
+ { "sched_setaffinity", (__NR_SYSCALL_BASE + 195) },
+ { "sched_setattr", (__NR_SYSCALL_BASE + 313) },
+ { "sched_setparam", (__NR_SYSCALL_BASE + 139) },
+ { "sched_setscheduler", (__NR_SYSCALL_BASE + 141) },
+ { "sched_yield", (__NR_SYSCALL_BASE + 23) },
+ { "security", __PNR_security },
+ { "select", __PNR_select },
+ { "semctl", (__NR_SYSCALL_BASE + 64) },
+ { "semget", (__NR_SYSCALL_BASE + 62) },
+ { "semop", (__NR_SYSCALL_BASE + 63) },
+ { "semtimedop", (__NR_SYSCALL_BASE + 215) },
+ { "send", __PNR_send },
+ { "sendfile", (__NR_SYSCALL_BASE + 39) },
+ { "sendfile64", (__NR_SYSCALL_BASE + 219) },
+ { "sendmmsg", (__NR_SYSCALL_BASE + 307) },
+ { "sendmsg", (__NR_SYSCALL_BASE + 45) },
+ { "sendto", (__NR_SYSCALL_BASE + 43) },
+ { "set_mempolicy", (__NR_SYSCALL_BASE + 233) },
+ { "set_robust_list", (__NR_SYSCALL_BASE + 272) },
+ { "set_thread_area", (__NR_SYSCALL_BASE + 246) },
+ { "set_tid_address", (__NR_SYSCALL_BASE + 213) },
+ { "setdomainname", (__NR_SYSCALL_BASE + 166) },
+ { "setfsgid", (__NR_SYSCALL_BASE + 121) },
+ { "setfsgid32", __PNR_setfsgid32 },
+ { "setfsuid", (__NR_SYSCALL_BASE + 120) },
+ { "setfsuid32", __PNR_setfsuid32 },
+ { "setgid", (__NR_SYSCALL_BASE + 104) },
+ { "setgid32", __PNR_setgid32 },
+ { "setgroups", (__NR_SYSCALL_BASE + 114) },
+ { "setgroups32", __PNR_setgroups32 },
+ { "sethostname", (__NR_SYSCALL_BASE + 165) },
+ { "setitimer", (__NR_SYSCALL_BASE + 36) },
+ { "setns", (__NR_SYSCALL_BASE + 308) },
+ { "setpgid", (__NR_SYSCALL_BASE + 107) },
+ { "setpriority", (__NR_SYSCALL_BASE + 138) },
+ { "setregid", (__NR_SYSCALL_BASE + 112) },
+ { "setregid32", __PNR_setregid32 },
+ { "setresgid", (__NR_SYSCALL_BASE + 117) },
+ { "setresgid32", __PNR_setresgid32 },
+ { "setresuid", (__NR_SYSCALL_BASE + 115) },
+ { "setresuid32", __PNR_setresuid32 },
+ { "setreuid", (__NR_SYSCALL_BASE + 111) },
+ { "setreuid32", __PNR_setreuid32 },
+ { "setrlimit", (__NR_SYSCALL_BASE + 155) },
+ { "setsid", (__NR_SYSCALL_BASE + 110) },
+ { "setsockopt", (__NR_SYSCALL_BASE + 53) },
+ { "settimeofday", (__NR_SYSCALL_BASE + 159) },
+ { "setuid", (__NR_SYSCALL_BASE + 103) },
+ { "setuid32", __PNR_setuid32 },
+ { "setxattr", (__NR_SYSCALL_BASE + 180) },
+ { "sgetmask", __PNR_sgetmask },
+ { "shmat", (__NR_SYSCALL_BASE + 29) },
+ { "shmctl", (__NR_SYSCALL_BASE + 30) },
+ { "shmdt", (__NR_SYSCALL_BASE + 65) },
+ { "shmget", (__NR_SYSCALL_BASE + 28) },
+ { "shutdown", (__NR_SYSCALL_BASE + 47) },
+ { "sigaction", __PNR_sigaction },
+ { "sigaltstack", (__NR_SYSCALL_BASE + 129) },
+ { "signal", __PNR_signal },
+ { "signalfd", (__NR_SYSCALL_BASE + 280) },
+ { "signalfd4", (__NR_SYSCALL_BASE + 287) },
+ { "sigpending", __PNR_sigpending },
+ { "sigprocmask", __PNR_sigprocmask },
+ { "sigreturn", __PNR_sigreturn },
+ { "sigsuspend", __PNR_sigsuspend },
+ { "socket", (__NR_SYSCALL_BASE + 40) },
+ { "socketcall", __PNR_socketcall },
+ { "socketpair", (__NR_SYSCALL_BASE + 52) },
+ { "splice", (__NR_SYSCALL_BASE + 267) },
+ { "ssetmask", __PNR_ssetmask },
+ { "stat", (__NR_SYSCALL_BASE + 4) },
+ { "stat64", __PNR_stat64 },
+ { "statfs", (__NR_SYSCALL_BASE + 134) },
+ { "statfs64", (__NR_SYSCALL_BASE + 217) },
+ { "stime", __PNR_stime },
+ { "stty", __PNR_stty },
+ { "swapoff", (__NR_SYSCALL_BASE + 163) },
+ { "swapon", (__NR_SYSCALL_BASE + 162) },
+ { "symlink", (__NR_SYSCALL_BASE + 86) },
+ { "symlinkat", (__NR_SYSCALL_BASE + 260) },
+ { "sync", (__NR_SYSCALL_BASE + 157) },
+ { "sync_file_range", (__NR_SYSCALL_BASE + 268) },
+ { "sync_file_range2", __PNR_sync_file_range2 },
+ { "syncfs", (__NR_SYSCALL_BASE + 306) },
+ { "syscall", __PNR_syscall },
+ { "sysfs", (__NR_SYSCALL_BASE + 136) },
+ { "sysinfo", (__NR_SYSCALL_BASE + 97) },
+ { "syslog", (__NR_SYSCALL_BASE + 101) },
+ { "sysmips", (__NR_SYSCALL_BASE + 199) },
+ { "tee", (__NR_SYSCALL_BASE + 269) },
+ { "tgkill", (__NR_SYSCALL_BASE + 229) },
+ { "time", __PNR_time },
+ { "timer_create", (__NR_SYSCALL_BASE + 220) },
+ { "timer_delete", (__NR_SYSCALL_BASE + 224) },
+ { "timer_getoverrun", (__NR_SYSCALL_BASE + 223) },
+ { "timer_gettime", (__NR_SYSCALL_BASE + 222) },
+ { "timer_settime", (__NR_SYSCALL_BASE + 221) },
+ { "timerfd", (__NR_SYSCALL_BASE + 281) },
+ { "timerfd_create", (__NR_SYSCALL_BASE + 284) },
+ { "timerfd_gettime", (__NR_SYSCALL_BASE + 285) },
+ { "timerfd_settime", (__NR_SYSCALL_BASE + 286) },
+ { "times", (__NR_SYSCALL_BASE + 98) },
+ { "tkill", (__NR_SYSCALL_BASE + 192) },
+ { "truncate", (__NR_SYSCALL_BASE + 74) },
+ { "truncate64", __PNR_truncate64 },
+ { "tuxcall", __PNR_tuxcall },
+ { "ugetrlimit", __PNR_ugetrlimit },
+ { "ulimit", __PNR_ulimit },
+ { "umask", (__NR_SYSCALL_BASE + 93) },
+ { "umount", __PNR_umount },
+ { "umount2", (__NR_SYSCALL_BASE + 161) },
+ { "uname", (__NR_SYSCALL_BASE + 61) },
+ { "unlink", (__NR_SYSCALL_BASE + 85) },
+ { "unlinkat", (__NR_SYSCALL_BASE + 257) },
+ { "unshare", (__NR_SYSCALL_BASE + 266) },
+ { "uselib", __PNR_uselib },
+ { "ustat", (__NR_SYSCALL_BASE + 133) },
+ { "utime", (__NR_SYSCALL_BASE + 130) },
+ { "utimensat", (__NR_SYSCALL_BASE + 279) },
+ { "utimes", (__NR_SYSCALL_BASE + 230) },
+ { "vfork", __PNR_vfork },
+ { "vhangup", (__NR_SYSCALL_BASE + 150) },
+ { "vm86", __PNR_vm86 },
+ { "vm86old", __PNR_vm86old },
+ { "vmsplice", (__NR_SYSCALL_BASE + 270) },
+ { "vserver", (__NR_SYSCALL_BASE + 240) },
+ { "wait4", (__NR_SYSCALL_BASE + 59) },
+ { "waitid", (__NR_SYSCALL_BASE + 241) },
+ { "waitpid", __PNR_waitpid },
+ { "write", (__NR_SYSCALL_BASE + 1) },
+ { "writev", (__NR_SYSCALL_BASE + 19) },
+ { NULL, __NR_SCMP_ERROR },
+};
+
+/**
+ * Resolve a syscall name to a number
+ * @param name the syscall name
+ *
+ * Resolve the given syscall name to the syscall number using the syscall table.
+ * Returns the syscall number on success, including negative pseudo syscall
+ * numbers; returns __NR_SCMP_ERROR on failure.
+ *
+ */
+int mips64n32_syscall_resolve_name(const char *name)
+{
+ unsigned int iter;
+ const struct arch_syscall_def *table = mips64n32_syscall_table;
+
+ /* XXX - plenty of room for future improvement here */
+ for (iter = 0; table[iter].name != NULL; iter++) {
+ if (strcmp(name, table[iter].name) == 0)
+ return table[iter].num;
+ }
+
+ return __NR_SCMP_ERROR;
+}
+
+/**
+ * Resolve a syscall number to a name
+ * @param num the syscall number
+ *
+ * Resolve the given syscall number to the syscall name using the syscall table.
+ * Returns a pointer to the syscall name string on success, including pseudo
+ * syscall names; returns NULL on failure.
+ *
+ */
+const char *mips64n32_syscall_resolve_num(int num)
+{
+ unsigned int iter;
+ const struct arch_syscall_def *table = mips64n32_syscall_table;
+
+ /* XXX - plenty of room for future improvement here */
+ for (iter = 0; table[iter].num != __NR_SCMP_ERROR; iter++) {
+ if (num == table[iter].num)
+ return table[iter].name;
+ }
+
+ return NULL;
+}
+
+/**
+ * Iterate through the syscall table and return the syscall name
+ * @param spot the offset into the syscall table
+ *
+ * Return the syscall name at position @spot or NULL on failure. This function
+ * should only ever be used internally by libseccomp.
+ *
+ */
+const char *mips64n32_syscall_iterate_name(unsigned int spot)
+{
+ /* XXX - no safety checks here */
+ return mips64n32_syscall_table[spot].name;
+}
diff --git a/src/arch-mips64n32.c b/src/arch-mips64n32.c
new file mode 100644
index 0000000..f00715b
--- /dev/null
+++ b/src/arch-mips64n32.c
@@ -0,0 +1,42 @@
+/**
+ * Enhanced Seccomp MIPS Specific Code
+ *
+ * Copyright (c) 2014 Red Hat <***@redhat.com>
+ * Author: Paul Moore <***@redhat.com>
+ *
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <linux/audit.h>
+
+#include "arch.h"
+#include "arch-mips64n32.h"
+
+const struct arch_def arch_def_mips64n32 = {
+ .token = SCMP_ARCH_MIPS64N32,
+ .token_bpf = AUDIT_ARCH_MIPS64N32,
+ .size = ARCH_SIZE_32,
+ .endian = ARCH_ENDIAN_BIG,
+};
+
+const struct arch_def arch_def_mipsel64n32 = {
+ .token = SCMP_ARCH_MIPSEL64N32,
+ .token_bpf = AUDIT_ARCH_MIPSEL64N32,
+ .size = ARCH_SIZE_32,
+ .endian = ARCH_ENDIAN_LITTLE,
+};
diff --git a/src/arch-mips64n32.h b/src/arch-mips64n32.h
new file mode 100644
index 0000000..441e646
--- /dev/null
+++ b/src/arch-mips64n32.h
@@ -0,0 +1,44 @@
+/**
+ * Enhanced Seccomp MIPS Specific Code
+ *
+ * Copyright (c) 2014 Red Hat <***@redhat.com>
+ * Author: Paul Moore <***@redhat.com>
+ *
+ */
+
+/*
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of version 2.1 of the GNU Lesser General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses>.
+ */
+
+#ifndef _ARCH_MIPS64N32_H
+#define _ARCH_MIPS64N32_H
+
+#include <inttypes.h>
+
+#include "arch.h"
+#include "system.h"
+
+#define mips64n32_arg_count_max 6
+
+extern const struct arch_def arch_def_mips64n32;
+extern const struct arch_def arch_def_mipsel64n32;
+
+#define mips64n32_arg_offset(x) (offsetof(struct seccomp_data, args[x]) + 4)
+#define mipsel64n32_arg_offset(x) (offsetof(struct seccomp_data, args[x]))
+
+int mips64n32_syscall_resolve_name(const char *name);
+const char *mips64n32_syscall_resolve_num(int num);
+
+const char *mips64n32_syscall_iterate_name(unsigned int spot);
+
+#endif
diff --git a/src/arch-syscall-check.c b/src/arch-syscall-check.c
index 664db5b..7a14a8b 100644
--- a/src/arch-syscall-check.c
+++ b/src/arch-syscall-check.c
@@ -30,6 +30,7 @@
#include "arch-arm.h"
#include "arch-mips.h"
#include "arch-mips64.h"
+#include "arch-mips64n32.h"
/**
* compare the syscall values
@@ -61,6 +62,7 @@ int main(int argc, char *argv[])
int i_arm = 0;
int i_mips = 0;
int i_mips64 = 0;
+ int i_mips64n32 = 0;
const char *sys_name, *tmp;
char str_miss[256];
@@ -71,14 +73,16 @@ int main(int argc, char *argv[])
sys_name = tmp;
/* check each arch using x86 as the reference */
- syscall_check(str_miss, sys_name,
- "x86_64", x86_64_syscall_iterate_name(i_x86_64));
- syscall_check(str_miss, sys_name,
- "arm", arm_syscall_iterate_name(i_arm));
- syscall_check(str_miss, sys_name,
- "mips", mips_syscall_iterate_name(i_mips));
- syscall_check(str_miss, sys_name,
- "mips64", mips64_syscall_iterate_name(i_mips64));
+ syscall_check(str_miss, sys_name, "x86_64",
+ x86_64_syscall_iterate_name(i_x86_64));
+ syscall_check(str_miss, sys_name, "arm",
+ arm_syscall_iterate_name(i_arm));
+ syscall_check(str_miss, sys_name, "mips",
+ mips_syscall_iterate_name(i_mips));
+ syscall_check(str_miss, sys_name, "mips64",
+ mips64_syscall_iterate_name(i_mips64));
+ syscall_check(str_miss, sys_name, "mips64n32",
+ mips64n32_syscall_iterate_name(i_mips64n32));
/* output the results */
printf("%s: ", sys_name);
@@ -99,7 +103,10 @@ int main(int argc, char *argv[])
i_mips = -1;
if (!mips64_syscall_iterate_name(++i_mips64))
i_mips64 = -1;
- } while (i_x86_64 >= 0 && i_arm >= 0 && i_mips >= 0 && i_mips64 >= 0);
+ if (!mips64n32_syscall_iterate_name(++i_mips64n32))
+ i_mips64n32 = -1;
+ } while (i_x86_64 >= 0 && i_arm >= 0 &&
+ i_mips >= 0 && i_mips64 >= 0 && i_mips64n32 >= 0);
/* check for any leftovers */
tmp = x86_syscall_iterate_name(i_x86 + 1);
@@ -127,6 +134,11 @@ int main(int argc, char *argv[])
mips64_syscall_iterate_name(i_mips));
return 1;
}
+ if (i_mips64n32 >= 0) {
+ printf("%s: ERROR, mips64n32 has additional syscalls\n",
+ mips64n32_syscall_iterate_name(i_mips));
+ return 1;
+ }
/* if we made it here, all is good */
return 0;
diff --git a/src/arch-syscall-dump.c b/src/arch-syscall-dump.c
index 29ea24a..9b5e181 100644
--- a/src/arch-syscall-dump.c
+++ b/src/arch-syscall-dump.c
@@ -36,6 +36,7 @@
#include "arch-arm.h"
#include "arch-mips.h"
#include "arch-mips64.h"
+#include "arch-mips64n32.h"
/**
* Print the usage information to stderr and exit
@@ -106,6 +107,10 @@ int main(int argc, char *argv[])
case SCMP_ARCH_MIPSEL64:
sys_name = mips64_syscall_iterate_name(iter);
break;
+ case SCMP_ARCH_MIPS64N32:
+ case SCMP_ARCH_MIPSEL64N32:
+ sys_name = mips64n32_syscall_iterate_name(iter);
+ break;
default:
/* invalid arch */
exit_usage(argv[0]);
diff --git a/src/arch-syscall-validate b/src/arch-syscall-validate
index 279dd87..e765c35 100755
--- a/src/arch-syscall-validate
+++ b/src/arch-syscall-validate
@@ -232,6 +232,39 @@ function dump_lib_mips64() {
}
#
+# Dump the mips64n32 system syscall table
+#
+# Arguments:
+# 1 path to the kernel source
+#
+# Dump the architecture's syscall table to stdout.
+#
+function dump_sys_mips64n32() {
+ # _MIPS_SIM values:
+ # _MIPS_SIM_ABI32 == 1
+ # _MIPS_SIM_NABI32 == 2
+ # _MIPS_SIM_ABI64 == 3
+ gcc -E -dM -I$1/arch/mips/include/uapi -D_MIPS_SIM=2 $1/arch/mips/include/uapi/asm/unistd.h | \
+ grep "^#define __NR_" | sort | \
+ grep -v "^#define __NR_O32_" | \
+ grep -v "^#define __NR_N32_" | \
+ grep -v "^#define __NR_64_" | \
+ grep -v "^#define __NR_Linux" | \
+ grep -v "^#define __NR_unused" | \
+ grep -v "^#define __NR_reserved" | \
+ sed -e 's/#define[ \t]\+__NR_\([^ \t]\+\)[ \t]\+(__NR_Linux[ \t]*+[ \t]*\([0-9]\+\)).*/\1\t\2/'
+}
+
+#
+# Dump the mips64n32 library syscall table
+#
+# Dump the library's syscall table to stdout.
+#
+function dump_lib_mips64n32() {
+ $LIB_SYS_DUMP -a mips64n32 -o 6000 | sed -e '/[^\t]\+\t-[0-9]\+/d'
+}
+
+#
# Dump the system syscall table
#
# Arguments:
@@ -260,6 +293,9 @@ function dump_sys() {
mips64)
dump_sys_mips64 "$2"
;;
+ mips64n32)
+ dump_sys_mips64n32 "$2"
+ ;;
*)
echo ""
;;
@@ -294,6 +330,9 @@ function dump_lib() {
mips64)
dump_lib_mips64 "$2"
;;
+ mips64n32)
+ dump_lib_mips64n32 "$2"
+ ;;
*)
echo ""
;;
diff --git a/src/arch.c b/src/arch.c
index 94bc3ed..370114d 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -36,6 +36,7 @@
#include "arch-arm.h"
#include "arch-mips.h"
#include "arch-mips64.h"
+#include "arch-mips64n32.h"
#include "system.h"
#if __i386__
@@ -60,6 +61,12 @@ const struct arch_def *arch_def_native = &arch_def_mips64;
#elif __MIPSEL__
const struct arch_def *arch_def_native = &arch_def_mipsel64;
#endif /* _MIPS_SIM_ABI64 */
+#elif _MIPS_SIM == _MIPS_SIM_NABI32
+#if __MIPSEB__
+const struct arch_def *arch_def_native = &arch_def_mips64n32;
+#elif __MIPSEL__
+const struct arch_def *arch_def_native = &arch_def_mipsel64n32;
+#endif /* _MIPS_SIM_NABI32 */
#else
#error the arch code needs to know about your machine type
#endif /* machine type guess */
@@ -82,6 +89,8 @@ int arch_valid(uint32_t arch)
case SCMP_ARCH_MIPSEL:
case SCMP_ARCH_MIPS64:
case SCMP_ARCH_MIPSEL64:
+ case SCMP_ARCH_MIPS64N32:
+ case SCMP_ARCH_MIPSEL64N32:
return 0;
}
@@ -114,6 +123,10 @@ const struct arch_def *arch_def_lookup(uint32_t token)
return &arch_def_mips64;
case SCMP_ARCH_MIPSEL64:
return &arch_def_mipsel64;
+ case SCMP_ARCH_MIPS64N32:
+ return &arch_def_mips64n32;
+ case SCMP_ARCH_MIPSEL64N32:
+ return &arch_def_mipsel64n32;
}
return NULL;
@@ -144,6 +157,10 @@ const struct arch_def *arch_def_lookup_name(const char *arch_name)
return &arch_def_mips64;
else if (strcmp(arch_name, "mipsel64") == 0)
return &arch_def_mipsel64;
+ else if (strcmp(arch_name, "mips64n32") == 0)
+ return &arch_def_mips64n32;
+ else if (strcmp(arch_name, "mipsel64n32") == 0)
+ return &arch_def_mipsel64n32;
return NULL;
}
@@ -173,6 +190,9 @@ int arch_arg_count_max(const struct arch_def *arch)
case SCMP_ARCH_MIPS64:
case SCMP_ARCH_MIPSEL64:
return mips64_arg_count_max;
+ case SCMP_ARCH_MIPS64N32:
+ case SCMP_ARCH_MIPSEL64N32:
+ return mips64n32_arg_count_max;
}
return -EDOM;
@@ -255,6 +275,10 @@ int arch_arg_offset(const struct arch_def *arch, unsigned int arg)
return mips64_arg_offset(arg);
case SCMP_ARCH_MIPSEL64:
return mipsel64_arg_offset(arg);
+ case SCMP_ARCH_MIPS64N32:
+ return mips64n32_arg_offset(arg);
+ case SCMP_ARCH_MIPSEL64N32:
+ return mipsel64n32_arg_offset(arg);
default:
return -EDOM;
}
@@ -287,6 +311,9 @@ int arch_syscall_resolve_name(const struct arch_def *arch, const char *name)
case SCMP_ARCH_MIPS64:
case SCMP_ARCH_MIPSEL64:
return mips64_syscall_resolve_name(name);
+ case SCMP_ARCH_MIPS64N32:
+ case SCMP_ARCH_MIPSEL64N32:
+ return mips64n32_syscall_resolve_name(name);
}
return __NR_SCMP_ERROR;
@@ -319,6 +346,9 @@ const char *arch_syscall_resolve_num(const struct arch_def *arch, int num)
case SCMP_ARCH_MIPS64:
case SCMP_ARCH_MIPSEL64:
return mips64_syscall_resolve_num(num);
+ case SCMP_ARCH_MIPS64N32:
+ case SCMP_ARCH_MIPSEL64N32:
+ return mips64n32_syscall_resolve_num(num);
}
return NULL;
diff --git a/src/gen_pfc.c b/src/gen_pfc.c
index ed7cc39..8fb66f1 100644
--- a/src/gen_pfc.c
+++ b/src/gen_pfc.c
@@ -65,6 +65,10 @@ static const char *_pfc_arch(const struct arch_def *arch)
return "mips64";
case SCMP_ARCH_MIPSEL64:
return "mipsel64";
+ case SCMP_ARCH_MIPS64N32:
+ return "mips64n32";
+ case SCMP_ARCH_MIPSEL64N32:
+ return "mipsel64n32";
default:
return "UNKNOWN";
}