Discussion:
[libseccomp-discuss] [PATCH 0/4] Add the mips64 and mips64n32 ABIs
Paul Moore
2014-08-20 15:45:12 UTC
Permalink
The subject says it all, two new MIPS ABIs, both in little and big
endian. I've tested the code on x86_64 and it looks reasonable, but
due to a lack of hardware I've been unable to do any actual MIPS
testing.

Markos, you said you would be able to verify the different MIPS ABIs,
could you test this code for us please?

-Paul

---

Paul Moore (4):
arch: add mips64 support
all: add support for mips64 to the tools and tests
arch: add mips64n32 support
all: add support for mips64n32 to the tools and tests


include/seccomp.h.in | 11 +
src/Makefile.am | 4
src/arch-mips64-syscalls.c | 493 +++++++++++++++++++++++++++++++++++++
src/arch-mips64.c | 40 +++
src/arch-mips64.h | 49 ++++
src/arch-mips64n32-syscalls.c | 493 +++++++++++++++++++++++++++++++++++++
src/arch-mips64n32.c | 42 +++
src/arch-mips64n32.h | 44 +++
src/arch-syscall-check.c | 37 ++-
src/arch-syscall-dump.c | 10 +
src/arch-syscall-validate | 80 ++++++
src/arch.c | 72 +++++
src/gen_pfc.c | 8 +
tests/16-sim-arch_basic.c | 6
tests/16-sim-arch_basic.py | 2
tests/23-sim-arch_all_le_basic.c | 6
tests/23-sim-arch_all_le_basic.py | 2
tests/26-sim-arch_all_be_basic.c | 6
tests/26-sim-arch_all_be_basic.py | 2
tests/regression | 6
tools/scmp_arch_detect.c | 12 +
tools/scmp_bpf_disasm.c | 8 +
tools/scmp_bpf_sim.c | 8 +
23 files changed, 1427 insertions(+), 14 deletions(-)
create mode 100644 src/arch-mips64-syscalls.c
create mode 100644 src/arch-mips64.c
create mode 100644 src/arch-mips64.h
create mode 100644 src/arch-mips64n32-syscalls.c
create mode 100644 src/arch-mips64n32.c
create mode 100644 src/arch-mips64n32.h
Paul Moore
2014-08-20 15:45:25 UTC
Permalink
Signed-off-by: Paul Moore <***@redhat.com>
---
tests/16-sim-arch_basic.c | 3 +++
tests/16-sim-arch_basic.py | 1 +
tests/23-sim-arch_all_le_basic.c | 3 +++
tests/23-sim-arch_all_le_basic.py | 1 +
tests/26-sim-arch_all_be_basic.c | 3 +++
tests/26-sim-arch_all_be_basic.py | 1 +
tests/regression | 6 +++---
tools/scmp_arch_detect.c | 6 ++++++
tools/scmp_bpf_disasm.c | 4 ++++
tools/scmp_bpf_sim.c | 4 ++++
10 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/tests/16-sim-arch_basic.c b/tests/16-sim-arch_basic.c
index 8e54c0a..f253f2c 100644
--- a/tests/16-sim-arch_basic.c
+++ b/tests/16-sim-arch_basic.c
@@ -59,6 +59,9 @@ int main(int argc, char *argv[])
rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL);
if (rc != 0)
goto out;
+ rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL64);
+ if (rc != 0)
+ goto out;

rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
diff --git a/tests/16-sim-arch_basic.py b/tests/16-sim-arch_basic.py
index e2020e3..671a1f4 100755
--- a/tests/16-sim-arch_basic.py
+++ b/tests/16-sim-arch_basic.py
@@ -36,6 +36,7 @@ def test(args):
f.add_arch(Arch("x32"))
f.add_arch(Arch("arm"))
f.add_arch(Arch("mipsel"))
+ f.add_arch(Arch("mipsel64"))
f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
diff --git a/tests/23-sim-arch_all_le_basic.c b/tests/23-sim-arch_all_le_basic.c
index 1035d1d..597482b 100644
--- a/tests/23-sim-arch_all_le_basic.c
+++ b/tests/23-sim-arch_all_le_basic.c
@@ -59,6 +59,9 @@ int main(int argc, char *argv[])
rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mipsel"));
if (rc != 0)
goto out;
+ rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mipsel64"));
+ if (rc != 0)
+ goto out;

rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
diff --git a/tests/23-sim-arch_all_le_basic.py b/tests/23-sim-arch_all_le_basic.py
index ba794ae..af77c86 100755
--- a/tests/23-sim-arch_all_le_basic.py
+++ b/tests/23-sim-arch_all_le_basic.py
@@ -36,6 +36,7 @@ def test(args):
f.add_arch(Arch("x32"))
f.add_arch(Arch("arm"))
f.add_arch(Arch("mipsel"))
+ f.add_arch(Arch("mipsel64"))
f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
diff --git a/tests/26-sim-arch_all_be_basic.c b/tests/26-sim-arch_all_be_basic.c
index 251dcf7..e2aab2a 100644
--- a/tests/26-sim-arch_all_be_basic.c
+++ b/tests/26-sim-arch_all_be_basic.c
@@ -46,6 +46,9 @@ int main(int argc, char *argv[])
rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mips"));
if (rc != 0)
goto out;
+ rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mips64"));
+ if (rc != 0)
+ goto out;

rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
diff --git a/tests/26-sim-arch_all_be_basic.py b/tests/26-sim-arch_all_be_basic.py
index 4c78252..e6635e3 100755
--- a/tests/26-sim-arch_all_be_basic.py
+++ b/tests/26-sim-arch_all_be_basic.py
@@ -31,6 +31,7 @@ def test(args):
f = SyscallFilter(KILL)
f.remove_arch(Arch())
f.add_arch(Arch("mips"))
+ f.add_arch(Arch("mips64"))
f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
diff --git a/tests/regression b/tests/regression
index b2e75a1..ee286c1 100755
--- a/tests/regression
+++ b/tests/regression
@@ -21,8 +21,8 @@
# along with this library; if not, see <http://www.gnu.org/licenses>.
#

-GLBL_ARCH_LE_SUPPORT="x86 x86_64 x32 arm mipsel"
-GLBL_ARCH_BE_SUPPORT="mips"
+GLBL_ARCH_LE_SUPPORT="x86 x86_64 x32 arm mipsel mipsel64"
+GLBL_ARCH_BE_SUPPORT="mips mips64"

GLBL_SYS_ARCH="../tools/scmp_arch_detect"
GLBL_SYS_RESOLVER="../tools/scmp_sys_resolver"
@@ -629,7 +629,7 @@ function run_test_live() {
rc_trace=162
rc_errno=163
;;
- mips|mipsel)
+ mips|mipsel|mips64|mipsel64)
rc_kill=140
rc_allow=160
rc_trap=161
diff --git a/tools/scmp_arch_detect.c b/tools/scmp_arch_detect.c
index 02d291b..217af84 100644
--- a/tools/scmp_arch_detect.c
+++ b/tools/scmp_arch_detect.c
@@ -84,6 +84,12 @@ int main(int argc, char *argv[])
case SCMP_ARCH_MIPSEL:
printf("mipsel\n");
break;
+ case SCMP_ARCH_MIPS64:
+ printf("mips64\n");
+ break;
+ case SCMP_ARCH_MIPSEL64:
+ printf("mipsel64\n");
+ break;
default:
printf("unknown\n");
}
diff --git a/tools/scmp_bpf_disasm.c b/tools/scmp_bpf_disasm.c
index d7babbe..ca99f07 100644
--- a/tools/scmp_bpf_disasm.c
+++ b/tools/scmp_bpf_disasm.c
@@ -324,6 +324,10 @@ int main(int argc, char *argv[])
arch = AUDIT_ARCH_MIPS;
else if (strcmp(optarg, "mipsel") == 0)
arch = AUDIT_ARCH_MIPSEL;
+ else if (strcmp(optarg, "mips64") == 0)
+ arch = AUDIT_ARCH_MIPS64;
+ else if (strcmp(optarg, "mipsel64") == 0)
+ arch = AUDIT_ARCH_MIPSEL64;
else
exit_usage(argv[0]);
break;
diff --git a/tools/scmp_bpf_sim.c b/tools/scmp_bpf_sim.c
index e910c64..fbe9df6 100644
--- a/tools/scmp_bpf_sim.c
+++ b/tools/scmp_bpf_sim.c
@@ -239,6 +239,10 @@ int main(int argc, char *argv[])
arch = AUDIT_ARCH_MIPS;
else if (strcmp(optarg, "mipsel") == 0)
arch = AUDIT_ARCH_MIPSEL;
+ else if (strcmp(optarg, "mips64") == 0)
+ arch = AUDIT_ARCH_MIPS64;
+ else if (strcmp(optarg, "mipsel64") == 0)
+ arch = AUDIT_ARCH_MIPSEL64;
else
exit_fault(EINVAL);
break;
Paul Moore
2014-08-20 15:45:18 UTC
Permalink
Signed-off-by: Paul Moore <***@redhat.com>
---
include/seccomp.h.in | 9 +
src/Makefile.am | 3
src/arch-mips64-syscalls.c | 493 ++++++++++++++++++++++++++++++++++++++++++++
src/arch-mips64.c | 40 ++++
src/arch-mips64.h | 49 ++++
src/arch-syscall-check.c | 13 +
src/arch-syscall-dump.c | 5
src/arch-syscall-validate | 41 ++++
src/arch.c | 42 ++++
src/gen_pfc.c | 4
10 files changed, 694 insertions(+), 5 deletions(-)
create mode 100644 src/arch-mips64-syscalls.c
create mode 100644 src/arch-mips64.c
create mode 100644 src/arch-mips64.h

diff --git a/include/seccomp.h.in b/include/seccomp.h.in
index b5f4dba..15c147e 100644
--- a/include/seccomp.h.in
+++ b/include/seccomp.h.in
@@ -122,10 +122,12 @@ struct scmp_arg_cmp {
#define SCMP_ARCH_ARM AUDIT_ARCH_ARM

/**
- * The MIPS architecture token
+ * The MIPS architecture tokens
*/
#define SCMP_ARCH_MIPS AUDIT_ARCH_MIPS
+#define SCMP_ARCH_MIPS64 AUDIT_ARCH_MIPS64
#define SCMP_ARCH_MIPSEL AUDIT_ARCH_MIPSEL
+#define SCMP_ARCH_MIPSEL64 AUDIT_ARCH_MIPSEL64

/**
* Convert a syscall name into the associated syscall number
@@ -1221,6 +1223,11 @@ int seccomp_export_bpf(const scmp_filter_ctx ctx, int fd);
#define __NR_timerfd __PNR_timerfd
#endif /* __NR_timerfd */

+#define __PNR_time -10108
+#ifndef __NR_time
+#define __NR_time __PNR_time
+#endif /* __NR_time */
+
#ifdef __cplusplus
}
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 893be69..5b737fd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,7 +27,8 @@ SOURCES_ARCH = \
arch-x86_64.h arch-x86_64.c arch-x86_64-syscalls.c \
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-mips.h arch-mips.c arch-mips-syscalls.c \
+ arch-mips64.h arch-mips64.c arch-mips64-syscalls.c

SOURCES_GEN = \
api.c system.h \
diff --git a/src/arch-mips64-syscalls.c b/src/arch-mips64-syscalls.c
new file mode 100644
index 0000000..4c667d9
--- /dev/null
+++ b/src/arch-mips64-syscalls.c
@@ -0,0 +1,493 @@
+/**
+ * Enhanced Seccomp MIPS64 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-mips64.h"
+
+/* 64 ABI */
+#define __NR_SYSCALL_BASE 5000
+
+/* NOTE: based on Linux 3.16-rc1 */
+const struct arch_syscall_def mips64_syscall_table[] = { \
+ { "_llseek", __PNR__llseek },
+ { "_newselect", (__NR_SYSCALL_BASE + 22) },
+ { "_sysctl", (__NR_SYSCALL_BASE + 152) },
+ { "accept", (__NR_SYSCALL_BASE + 42) },
+ { "accept4", (__NR_SYSCALL_BASE + 293) },
+ { "access", (__NR_SYSCALL_BASE + 20) },
+ { "acct", (__NR_SYSCALL_BASE + 158) },
+ { "add_key", (__NR_SYSCALL_BASE + 239) },
+ { "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 + 300) },
+ { "clock_getres", (__NR_SYSCALL_BASE + 223) },
+ { "clock_gettime", (__NR_SYSCALL_BASE + 222) },
+ { "clock_nanosleep", (__NR_SYSCALL_BASE + 224) },
+ { "clock_settime", (__NR_SYSCALL_BASE + 221) },
+ { "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 + 286) },
+ { "epoll_create", (__NR_SYSCALL_BASE + 207) },
+ { "epoll_create1", (__NR_SYSCALL_BASE + 285) },
+ { "epoll_ctl", (__NR_SYSCALL_BASE + 208) },
+ { "epoll_ctl_old", __PNR_epoll_ctl_old },
+ { "epoll_pwait", (__NR_SYSCALL_BASE + 272) },
+ { "epoll_wait", (__NR_SYSCALL_BASE + 209) },
+ { "epoll_wait_old", __PNR_epoll_wait_old },
+ { "eventfd", (__NR_SYSCALL_BASE + 278) },
+ { "eventfd2", (__NR_SYSCALL_BASE + 284) },
+ { "execve", (__NR_SYSCALL_BASE + 57) },
+ { "exit", (__NR_SYSCALL_BASE + 58) },
+ { "exit_group", (__NR_SYSCALL_BASE + 205) },
+ { "faccessat", (__NR_SYSCALL_BASE + 259) },
+ { "fadvise64", (__NR_SYSCALL_BASE + 215) },
+ { "fadvise64_64", __PNR_fadvise64_64 },
+ { "fallocate", (__NR_SYSCALL_BASE + 279) },
+ { "fanotify_init", (__NR_SYSCALL_BASE + 295) },
+ { "fanotify_mark", (__NR_SYSCALL_BASE + 296) },
+ { "fchdir", (__NR_SYSCALL_BASE + 79) },
+ { "fchmod", (__NR_SYSCALL_BASE + 89) },
+ { "fchmodat", (__NR_SYSCALL_BASE + 258) },
+ { "fchown", (__NR_SYSCALL_BASE + 91) },
+ { "fchown32", __PNR_fchown32 },
+ { "fchownat", (__NR_SYSCALL_BASE + 250) },
+ { "fcntl", (__NR_SYSCALL_BASE + 70) },
+ { "fcntl64", __PNR_fcntl64 },
+ { "fdatasync", (__NR_SYSCALL_BASE + 73) },
+ { "fgetxattr", (__NR_SYSCALL_BASE + 185) },
+ { "finit_module", (__NR_SYSCALL_BASE + 307) },
+ { "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", __PNR_fstatfs64 },
+ { "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 + 251) },
+ { "get_kernel_syms", (__NR_SYSCALL_BASE + 170) },
+ { "get_mempolicy", (__NR_SYSCALL_BASE + 228) },
+ { "get_robust_list", (__NR_SYSCALL_BASE + 269) },
+ { "get_thread_area", __PNR_get_thread_area },
+ { "getcpu", (__NR_SYSCALL_BASE + 271) },
+ { "getcwd", (__NR_SYSCALL_BASE + 77) },
+ { "getdents", (__NR_SYSCALL_BASE + 76) },
+ { "getdents64", (__NR_SYSCALL_BASE + 308) },
+ { "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 + 244) },
+ { "inotify_init", (__NR_SYSCALL_BASE + 243) },
+ { "inotify_init1", (__NR_SYSCALL_BASE + 288) },
+ { "inotify_rm_watch", (__NR_SYSCALL_BASE + 245) },
+ { "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 + 274) },
+ { "ioprio_set", (__NR_SYSCALL_BASE + 273) },
+ { "ipc", __PNR_ipc },
+ { "kcmp", (__NR_SYSCALL_BASE + 306) },
+ { "kexec_load", (__NR_SYSCALL_BASE + 270) },
+ { "keyctl", (__NR_SYSCALL_BASE + 241) },
+ { "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 + 255) },
+ { "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 + 227) },
+ { "migrate_pages", (__NR_SYSCALL_BASE + 246) },
+ { "mincore", (__NR_SYSCALL_BASE + 26) },
+ { "mkdir", (__NR_SYSCALL_BASE + 81) },
+ { "mkdirat", (__NR_SYSCALL_BASE + 248) },
+ { "mknod", (__NR_SYSCALL_BASE + 131) },
+ { "mknodat", (__NR_SYSCALL_BASE + 249) },
+ { "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 + 267) },
+ { "mprotect", (__NR_SYSCALL_BASE + 10) },
+ { "mpx", __PNR_mpx },
+ { "mq_getsetattr", (__NR_SYSCALL_BASE + 235) },
+ { "mq_notify", (__NR_SYSCALL_BASE + 234) },
+ { "mq_open", (__NR_SYSCALL_BASE + 230) },
+ { "mq_timedreceive", (__NR_SYSCALL_BASE + 233) },
+ { "mq_timedsend", (__NR_SYSCALL_BASE + 232) },
+ { "mq_unlink", (__NR_SYSCALL_BASE + 231) },
+ { "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 + 298) },
+ { "nanosleep", (__NR_SYSCALL_BASE + 34) },
+ { "newfstatat", (__NR_SYSCALL_BASE + 252) },
+ { "nfsservctl", __PNR_nfsservctl },
+ { "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 + 299) },
+ { "openat", (__NR_SYSCALL_BASE + 247) },
+ { "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 + 292) },
+ { "personality", (__NR_SYSCALL_BASE + 132) },
+ { "pipe", (__NR_SYSCALL_BASE + 21) },
+ { "pipe2", (__NR_SYSCALL_BASE + 287) },
+ { "pivot_root", (__NR_SYSCALL_BASE + 151) },
+ { "poll", (__NR_SYSCALL_BASE + 7) },
+ { "ppoll", (__NR_SYSCALL_BASE + 261) },
+ { "prctl", (__NR_SYSCALL_BASE + 153) },
+ { "pread64", (__NR_SYSCALL_BASE + 16) },
+ { "preadv", (__NR_SYSCALL_BASE + 289) },
+ { "prlimit64", (__NR_SYSCALL_BASE + 297) },
+ { "process_vm_readv", (__NR_SYSCALL_BASE + 304) },
+ { "process_vm_writev", (__NR_SYSCALL_BASE + 305) },
+ { "prof", __PNR_prof },
+ { "profil", __PNR_profil },
+ { "pselect6", (__NR_SYSCALL_BASE + 260) },
+ { "ptrace", (__NR_SYSCALL_BASE + 99) },
+ { "putpmsg", (__NR_SYSCALL_BASE + 175) },
+ { "pwrite64", (__NR_SYSCALL_BASE + 17) },
+ { "pwritev", (__NR_SYSCALL_BASE + 290) },
+ { "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 + 257) },
+ { "readv", (__NR_SYSCALL_BASE + 18) },
+ { "reboot", (__NR_SYSCALL_BASE + 164) },
+ { "recv", __PNR_recv },
+ { "recvfrom", (__NR_SYSCALL_BASE + 44) },
+ { "recvmmsg", (__NR_SYSCALL_BASE + 294) },
+ { "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 + 254) },
+ { "renameat2", (__NR_SYSCALL_BASE + 311) },
+ { "request_key", (__NR_SYSCALL_BASE + 240) },
+ { "restart_syscall", (__NR_SYSCALL_BASE + 213) },
+ { "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 + 291) },
+ { "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 + 310) },
+ { "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 + 309) },
+ { "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 + 214) },
+ { "send", __PNR_send },
+ { "sendfile", (__NR_SYSCALL_BASE + 39) },
+ { "sendfile64", __PNR_sendfile64 },
+ { "sendmmsg", (__NR_SYSCALL_BASE + 302) },
+ { "sendmsg", (__NR_SYSCALL_BASE + 45) },
+ { "sendto", (__NR_SYSCALL_BASE + 43) },
+ { "set_mempolicy", (__NR_SYSCALL_BASE + 229) },
+ { "set_robust_list", (__NR_SYSCALL_BASE + 268) },
+ { "set_thread_area", (__NR_SYSCALL_BASE + 242) },
+ { "set_tid_address", (__NR_SYSCALL_BASE + 212) },
+ { "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 + 303) },
+ { "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 + 276) },
+ { "signalfd4", (__NR_SYSCALL_BASE + 283) },
+ { "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 + 263) },
+ { "ssetmask", __PNR_ssetmask },
+ { "stat", (__NR_SYSCALL_BASE + 4) },
+ { "stat64", __PNR_stat64 },
+ { "statfs", (__NR_SYSCALL_BASE + 134) },
+ { "statfs64", __PNR_statfs64 },
+ { "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 + 256) },
+ { "sync", (__NR_SYSCALL_BASE + 157) },
+ { "sync_file_range", (__NR_SYSCALL_BASE + 264) },
+ { "sync_file_range2", __PNR_sync_file_range2 },
+ { "syncfs", (__NR_SYSCALL_BASE + 301) },
+ { "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 + 265) },
+ { "tgkill", (__NR_SYSCALL_BASE + 225) },
+ { "time", __PNR_time },
+ { "timer_create", (__NR_SYSCALL_BASE + 216) },
+ { "timer_delete", (__NR_SYSCALL_BASE + 220) },
+ { "timer_getoverrun", (__NR_SYSCALL_BASE + 219) },
+ { "timer_gettime", (__NR_SYSCALL_BASE + 218) },
+ { "timer_settime", (__NR_SYSCALL_BASE + 217) },
+ { "timerfd", (__NR_SYSCALL_BASE + 277) },
+ { "timerfd_create", (__NR_SYSCALL_BASE + 280) },
+ { "timerfd_gettime", (__NR_SYSCALL_BASE + 281) },
+ { "timerfd_settime", (__NR_SYSCALL_BASE + 282) },
+ { "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 + 253) },
+ { "unshare", (__NR_SYSCALL_BASE + 262) },
+ { "uselib", __PNR_uselib },
+ { "ustat", (__NR_SYSCALL_BASE + 133) },
+ { "utime", (__NR_SYSCALL_BASE + 130) },
+ { "utimensat", (__NR_SYSCALL_BASE + 275) },
+ { "utimes", (__NR_SYSCALL_BASE + 226) },
+ { "vfork", __PNR_vfork },
+ { "vhangup", (__NR_SYSCALL_BASE + 150) },
+ { "vm86", __PNR_vm86 },
+ { "vm86old", __PNR_vm86old },
+ { "vmsplice", (__NR_SYSCALL_BASE + 266) },
+ { "vserver", (__NR_SYSCALL_BASE + 236) },
+ { "wait4", (__NR_SYSCALL_BASE + 59) },
+ { "waitid", (__NR_SYSCALL_BASE + 237) },
+ { "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 mips64_syscall_resolve_name(const char *name)
+{
+ unsigned int iter;
+ const struct arch_syscall_def *table = mips64_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 *mips64_syscall_resolve_num(int num)
+{
+ unsigned int iter;
+ const struct arch_syscall_def *table = mips64_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 *mips64_syscall_iterate_name(unsigned int spot)
+{
+ /* XXX - no safety checks here */
+ return mips64_syscall_table[spot].name;
+}
diff --git a/src/arch-mips64.c b/src/arch-mips64.c
new file mode 100644
index 0000000..b8a33c5
--- /dev/null
+++ b/src/arch-mips64.c
@@ -0,0 +1,40 @@
+/**
+ * Enhanced Seccomp MIPS64 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 <linux/audit.h>
+
+#include "arch.h"
+#include "arch-mips64.h"
+
+const struct arch_def arch_def_mips64 = {
+ .token = SCMP_ARCH_MIPS64,
+ .token_bpf = AUDIT_ARCH_MIPS64,
+ .size = ARCH_SIZE_64,
+ .endian = ARCH_ENDIAN_BIG,
+};
+
+const struct arch_def arch_def_mipsel64 = {
+ .token = SCMP_ARCH_MIPSEL64,
+ .token_bpf = AUDIT_ARCH_MIPSEL64,
+ .size = ARCH_SIZE_64,
+ .endian = ARCH_ENDIAN_LITTLE,
+};
diff --git a/src/arch-mips64.h b/src/arch-mips64.h
new file mode 100644
index 0000000..662ba51
--- /dev/null
+++ b/src/arch-mips64.h
@@ -0,0 +1,49 @@
+/**
+ * Enhanced Seccomp MIPS64 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_MIPS64_H
+#define _ARCH_MIPS64_H
+
+#include <inttypes.h>
+
+#include "arch.h"
+#include "system.h"
+
+#define mips64_arg_count_max 6
+
+extern const struct arch_def arch_def_mips64;
+extern const struct arch_def arch_def_mipsel64;
+
+#define mips64_arg_offset(x) (offsetof(struct seccomp_data, args[x]))
+#define mips64_arg_offset_lo(x) (mips64_arg_offset(x) + 4)
+#define mips64_arg_offset_hi(x) (mips64_arg_offset(x))
+
+#define mipsel64_arg_offset(x) (offsetof(struct seccomp_data, args[x]))
+#define mipsel64_arg_offset_lo(x) (mipsel64_arg_offset(x))
+#define mipsel64_arg_offset_hi(x) (mipsel64_arg_offset(x) + 4)
+
+int mips64_syscall_resolve_name(const char *name);
+const char *mips64_syscall_resolve_num(int num);
+
+const char *mips64_syscall_iterate_name(unsigned int spot);
+
+#endif
\ No newline at end of file
diff --git a/src/arch-syscall-check.c b/src/arch-syscall-check.c
index 22fd139..664db5b 100644
--- a/src/arch-syscall-check.c
+++ b/src/arch-syscall-check.c
@@ -29,6 +29,7 @@
#include "arch-x86_64.h"
#include "arch-arm.h"
#include "arch-mips.h"
+#include "arch-mips64.h"

/**
* compare the syscall values
@@ -59,6 +60,7 @@ int main(int argc, char *argv[])
int i_x86_64 = 0;
int i_arm = 0;
int i_mips = 0;
+ int i_mips64 = 0;
const char *sys_name, *tmp;
char str_miss[256];

@@ -75,6 +77,8 @@ int main(int argc, char *argv[])
"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));

/* output the results */
printf("%s: ", sys_name);
@@ -93,7 +97,9 @@ int main(int argc, char *argv[])
i_arm = -1;
if (!mips_syscall_iterate_name(++i_mips))
i_mips = -1;
- } while (i_x86_64 >= 0 && i_arm >= 0 && i_mips >= 0);
+ if (!mips64_syscall_iterate_name(++i_mips64))
+ i_mips64 = -1;
+ } while (i_x86_64 >= 0 && i_arm >= 0 && i_mips >= 0 && i_mips64 >= 0);

/* check for any leftovers */
tmp = x86_syscall_iterate_name(i_x86 + 1);
@@ -116,6 +122,11 @@ int main(int argc, char *argv[])
mips_syscall_iterate_name(i_mips));
return 1;
}
+ if (i_mips64 >= 0) {
+ printf("%s: ERROR, mips64 has additional syscalls\n",
+ mips64_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 70028ec..29ea24a 100644
--- a/src/arch-syscall-dump.c
+++ b/src/arch-syscall-dump.c
@@ -35,6 +35,7 @@
#include "arch-x32.h"
#include "arch-arm.h"
#include "arch-mips.h"
+#include "arch-mips64.h"

/**
* Print the usage information to stderr and exit
@@ -101,6 +102,10 @@ int main(int argc, char *argv[])
case SCMP_ARCH_MIPSEL:
sys_name = mips_syscall_iterate_name(iter);
break;
+ case SCMP_ARCH_MIPS64:
+ case SCMP_ARCH_MIPSEL64:
+ sys_name = mips64_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 5d2e9aa..279dd87 100755
--- a/src/arch-syscall-validate
+++ b/src/arch-syscall-validate
@@ -199,6 +199,39 @@ function dump_lib_mips() {
}

#
+# Dump the mips64 system syscall table
+#
+# Arguments:
+# 1 path to the kernel source
+#
+# Dump the architecture's syscall table to stdout.
+#
+function dump_sys_mips64() {
+ # _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=3 $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 mips64 library syscall table
+#
+# Dump the library's syscall table to stdout.
+#
+function dump_lib_mips64() {
+ $LIB_SYS_DUMP -a mips64 -o 5000 | sed -e '/[^\t]\+\t-[0-9]\+/d'
+}
+
+#
# Dump the system syscall table
#
# Arguments:
@@ -224,6 +257,9 @@ function dump_sys() {
mips)
dump_sys_mips "$2"
;;
+ mips64)
+ dump_sys_mips64 "$2"
+ ;;
*)
echo ""
;;
@@ -255,6 +291,9 @@ function dump_lib() {
mips)
dump_lib_mips "$2"
;;
+ mips64)
+ dump_lib_mips64 "$2"
+ ;;
*)
echo ""
;;
@@ -290,7 +329,7 @@ done
shift $(($OPTIND - 1))

# defaults
-[[ $arches == "" ]] && arches="x86 x86_64 x32 arm mips"
+[[ $arches == "" ]] && arches="x86 x86_64 x32 arm mips mips64"

# sanity checks
kernel_dir="$1"
diff --git a/src/arch.c b/src/arch.c
index 2d2644d..94bc3ed 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -35,6 +35,7 @@
#include "arch-x32.h"
#include "arch-arm.h"
#include "arch-mips.h"
+#include "arch-mips64.h"
#include "system.h"

#if __i386__
@@ -47,10 +48,18 @@ const struct arch_def *arch_def_native = &arch_def_x86_64;
#endif /* __ILP32__ */
#elif __arm__
const struct arch_def *arch_def_native = &arch_def_arm;
-#elif __MIPSEB__
+#elif _MIPS_SIM == _MIPS_SIM_ABI32
+#if __MIPSEB__
const struct arch_def *arch_def_native = &arch_def_mips;
#elif __MIPSEL__
const struct arch_def *arch_def_native = &arch_def_mipsel;
+#endif /* _MIPS_SIM_ABI32 */
+#elif _MIPS_SIM == _MIPS_SIM_ABI64
+#if __MIPSEB__
+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 */
#else
#error the arch code needs to know about your machine type
#endif /* machine type guess */
@@ -71,6 +80,8 @@ int arch_valid(uint32_t arch)
case SCMP_ARCH_ARM:
case SCMP_ARCH_MIPS:
case SCMP_ARCH_MIPSEL:
+ case SCMP_ARCH_MIPS64:
+ case SCMP_ARCH_MIPSEL64:
return 0;
}

@@ -99,6 +110,10 @@ const struct arch_def *arch_def_lookup(uint32_t token)
return &arch_def_mips;
case SCMP_ARCH_MIPSEL:
return &arch_def_mipsel;
+ case SCMP_ARCH_MIPS64:
+ return &arch_def_mips64;
+ case SCMP_ARCH_MIPSEL64:
+ return &arch_def_mipsel64;
}

return NULL;
@@ -125,6 +140,10 @@ const struct arch_def *arch_def_lookup_name(const char *arch_name)
return &arch_def_mips;
else if (strcmp(arch_name, "mipsel") == 0)
return &arch_def_mipsel;
+ else if (strcmp(arch_name, "mips64") == 0)
+ return &arch_def_mips64;
+ else if (strcmp(arch_name, "mipsel64") == 0)
+ return &arch_def_mipsel64;

return NULL;
}
@@ -151,6 +170,9 @@ int arch_arg_count_max(const struct arch_def *arch)
case SCMP_ARCH_MIPS:
case SCMP_ARCH_MIPSEL:
return mips_arg_count_max;
+ case SCMP_ARCH_MIPS64:
+ case SCMP_ARCH_MIPSEL64:
+ return mips64_arg_count_max;
}

return -EDOM;
@@ -171,6 +193,10 @@ int arch_arg_offset_lo(const struct arch_def *arch, unsigned int arg)
switch (arch->token) {
case SCMP_ARCH_X86_64:
return x86_64_arg_offset_lo(arg);
+ case SCMP_ARCH_MIPS64:
+ return mips64_arg_offset_lo(arg);
+ case SCMP_ARCH_MIPSEL64:
+ return mipsel64_arg_offset_lo(arg);
default:
return -EDOM;
}
@@ -191,6 +217,10 @@ int arch_arg_offset_hi(const struct arch_def *arch, unsigned int arg)
switch (arch->token) {
case SCMP_ARCH_X86_64:
return x86_64_arg_offset_hi(arg);
+ case SCMP_ARCH_MIPS64:
+ return mips64_arg_offset_hi(arg);
+ case SCMP_ARCH_MIPSEL64:
+ return mipsel64_arg_offset_hi(arg);
default:
return -EDOM;
}
@@ -221,6 +251,10 @@ int arch_arg_offset(const struct arch_def *arch, unsigned int arg)
return mips_arg_offset(arg);
case SCMP_ARCH_MIPSEL:
return mipsel_arg_offset(arg);
+ case SCMP_ARCH_MIPS64:
+ return mips64_arg_offset(arg);
+ case SCMP_ARCH_MIPSEL64:
+ return mipsel64_arg_offset(arg);
default:
return -EDOM;
}
@@ -250,6 +284,9 @@ int arch_syscall_resolve_name(const struct arch_def *arch, const char *name)
case SCMP_ARCH_MIPS:
case SCMP_ARCH_MIPSEL:
return mips_syscall_resolve_name(name);
+ case SCMP_ARCH_MIPS64:
+ case SCMP_ARCH_MIPSEL64:
+ return mips64_syscall_resolve_name(name);
}

return __NR_SCMP_ERROR;
@@ -279,6 +316,9 @@ const char *arch_syscall_resolve_num(const struct arch_def *arch, int num)
case SCMP_ARCH_MIPS:
case SCMP_ARCH_MIPSEL:
return mips_syscall_resolve_num(num);
+ case SCMP_ARCH_MIPS64:
+ case SCMP_ARCH_MIPSEL64:
+ return mips64_syscall_resolve_num(num);
}

return NULL;
diff --git a/src/gen_pfc.c b/src/gen_pfc.c
index de0a2de..ed7cc39 100644
--- a/src/gen_pfc.c
+++ b/src/gen_pfc.c
@@ -61,6 +61,10 @@ static const char *_pfc_arch(const struct arch_def *arch)
return "mips";
case SCMP_ARCH_MIPSEL:
return "mipsel";
+ case SCMP_ARCH_MIPS64:
+ return "mips64";
+ case SCMP_ARCH_MIPSEL64:
+ return "mipsel64";
default:
return "UNKNOWN";
}
Marcin Juszkiewicz
2014-08-21 09:22:27 UTC
Permalink
Paul Moore
2014-08-21 12:51:12 UTC
Permalink
On Thursday, August 21, 2014 11:22:27 AM Marcin Juszkiewicz wrote:
Paul Moore
2014-08-21 12:54:49 UTC
Permalink
Marcin Juszkiewicz
2014-08-21 13:59:53 UTC
Permalink
Paul Moore
2014-08-21 18:48:57 UTC
Permalink
Markos Chandras
2014-08-21 13:08:36 UTC
Permalink
Hi,

On Thu, Aug 21, 2014 at 11:22:27AM +0200, Marcin Juszkiewicz wrote:
Paul Moore
2014-08-21 18:50:57 UTC
Permalink
Hi,
Paul Moore
2014-08-20 15:45:33 UTC
Permalink
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";
}
Paul Moore
2014-08-20 15:45:40 UTC
Permalink
Signed-off-by: Paul Moore <***@redhat.com>
---
tests/16-sim-arch_basic.c | 3 +++
tests/16-sim-arch_basic.py | 1 +
tests/23-sim-arch_all_le_basic.c | 3 +++
tests/23-sim-arch_all_le_basic.py | 1 +
tests/26-sim-arch_all_be_basic.c | 3 +++
tests/26-sim-arch_all_be_basic.py | 1 +
tests/regression | 4 ++--
tools/scmp_arch_detect.c | 6 ++++++
tools/scmp_bpf_disasm.c | 4 ++++
tools/scmp_bpf_sim.c | 4 ++++
10 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tests/16-sim-arch_basic.c b/tests/16-sim-arch_basic.c
index f253f2c..efc8696 100644
--- a/tests/16-sim-arch_basic.c
+++ b/tests/16-sim-arch_basic.c
@@ -62,6 +62,9 @@ int main(int argc, char *argv[])
rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL64);
if (rc != 0)
goto out;
+ rc = seccomp_arch_add(ctx, SCMP_ARCH_MIPSEL64N32);
+ if (rc != 0)
+ goto out;

rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
diff --git a/tests/16-sim-arch_basic.py b/tests/16-sim-arch_basic.py
index 671a1f4..ddd3f65 100755
--- a/tests/16-sim-arch_basic.py
+++ b/tests/16-sim-arch_basic.py
@@ -37,6 +37,7 @@ def test(args):
f.add_arch(Arch("arm"))
f.add_arch(Arch("mipsel"))
f.add_arch(Arch("mipsel64"))
+ f.add_arch(Arch("mipsel64n32"))
f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
diff --git a/tests/23-sim-arch_all_le_basic.c b/tests/23-sim-arch_all_le_basic.c
index 597482b..9e820e1 100644
--- a/tests/23-sim-arch_all_le_basic.c
+++ b/tests/23-sim-arch_all_le_basic.c
@@ -62,6 +62,9 @@ int main(int argc, char *argv[])
rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mipsel64"));
if (rc != 0)
goto out;
+ rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mipsel64n32"));
+ if (rc != 0)
+ goto out;

rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
diff --git a/tests/23-sim-arch_all_le_basic.py b/tests/23-sim-arch_all_le_basic.py
index af77c86..eba5152 100755
--- a/tests/23-sim-arch_all_le_basic.py
+++ b/tests/23-sim-arch_all_le_basic.py
@@ -37,6 +37,7 @@ def test(args):
f.add_arch(Arch("arm"))
f.add_arch(Arch("mipsel"))
f.add_arch(Arch("mipsel64"))
+ f.add_arch(Arch("mipsel64n32"))
f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
diff --git a/tests/26-sim-arch_all_be_basic.c b/tests/26-sim-arch_all_be_basic.c
index e2aab2a..a951b3c 100644
--- a/tests/26-sim-arch_all_be_basic.c
+++ b/tests/26-sim-arch_all_be_basic.c
@@ -49,6 +49,9 @@ int main(int argc, char *argv[])
rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mips64"));
if (rc != 0)
goto out;
+ rc = seccomp_arch_add(ctx, seccomp_arch_resolve_name("mips64n32"));
+ if (rc != 0)
+ goto out;

rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(read), 1,
SCMP_A0(SCMP_CMP_EQ, STDIN_FILENO));
diff --git a/tests/26-sim-arch_all_be_basic.py b/tests/26-sim-arch_all_be_basic.py
index e6635e3..1347406 100755
--- a/tests/26-sim-arch_all_be_basic.py
+++ b/tests/26-sim-arch_all_be_basic.py
@@ -32,6 +32,7 @@ def test(args):
f.remove_arch(Arch())
f.add_arch(Arch("mips"))
f.add_arch(Arch("mips64"))
+ f.add_arch(Arch("mips64n32"))
f.add_rule(ALLOW, "read", Arg(0, EQ, sys.stdin.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stdout.fileno()))
f.add_rule(ALLOW, "write", Arg(0, EQ, sys.stderr.fileno()))
diff --git a/tests/regression b/tests/regression
index ee286c1..29ea5a0 100755
--- a/tests/regression
+++ b/tests/regression
@@ -21,8 +21,8 @@
# along with this library; if not, see <http://www.gnu.org/licenses>.
#

-GLBL_ARCH_LE_SUPPORT="x86 x86_64 x32 arm mipsel mipsel64"
-GLBL_ARCH_BE_SUPPORT="mips mips64"
+GLBL_ARCH_LE_SUPPORT="x86 x86_64 x32 arm mipsel mipsel64 mipsel64n32"
+GLBL_ARCH_BE_SUPPORT="mips mips64 mips64n32"

GLBL_SYS_ARCH="../tools/scmp_arch_detect"
GLBL_SYS_RESOLVER="../tools/scmp_sys_resolver"
diff --git a/tools/scmp_arch_detect.c b/tools/scmp_arch_detect.c
index 217af84..d7f91b3 100644
--- a/tools/scmp_arch_detect.c
+++ b/tools/scmp_arch_detect.c
@@ -90,6 +90,12 @@ int main(int argc, char *argv[])
case SCMP_ARCH_MIPSEL64:
printf("mipsel64\n");
break;
+ case SCMP_ARCH_MIPS64N32:
+ printf("mips64n32\n");
+ break;
+ case SCMP_ARCH_MIPSEL64N32:
+ printf("mipsel64n32\n");
+ break;
default:
printf("unknown\n");
}
diff --git a/tools/scmp_bpf_disasm.c b/tools/scmp_bpf_disasm.c
index ca99f07..98021dc 100644
--- a/tools/scmp_bpf_disasm.c
+++ b/tools/scmp_bpf_disasm.c
@@ -328,6 +328,10 @@ int main(int argc, char *argv[])
arch = AUDIT_ARCH_MIPS64;
else if (strcmp(optarg, "mipsel64") == 0)
arch = AUDIT_ARCH_MIPSEL64;
+ else if (strcmp(optarg, "mips64n32") == 0)
+ arch = AUDIT_ARCH_MIPS64N32;
+ else if (strcmp(optarg, "mipsel64n32") == 0)
+ arch = AUDIT_ARCH_MIPSEL64N32;
else
exit_usage(argv[0]);
break;
diff --git a/tools/scmp_bpf_sim.c b/tools/scmp_bpf_sim.c
index fbe9df6..c9333f3 100644
--- a/tools/scmp_bpf_sim.c
+++ b/tools/scmp_bpf_sim.c
@@ -243,6 +243,10 @@ int main(int argc, char *argv[])
arch = AUDIT_ARCH_MIPS64;
else if (strcmp(optarg, "mipsel64") == 0)
arch = AUDIT_ARCH_MIPSEL64;
+ else if (strcmp(optarg, "mips64n32") == 0)
+ arch = AUDIT_ARCH_MIPS64N32;
+ else if (strcmp(optarg, "mipsel64n32") == 0)
+ arch = AUDIT_ARCH_MIPSEL64N32;
else
exit_fault(EINVAL);
break;
Markos Chandras
2014-08-21 08:16:36 UTC
Permalink
Post by Paul Moore
The subject says it all, two new MIPS ABIs, both in little and big
endian. I've tested the code on x86_64 and it looks reasonable, but
due to a lack of hardware I've been unable to do any actual MIPS
testing.
Markos, you said you would be able to verify the different MIPS ABIs,
could you test this code for us please?
-Paul
Hi Paul,

Thanks for the patch. I will give it a go next week.
--
markos
Paul Moore
2014-08-21 12:58:05 UTC
Permalink
Post by Markos Chandras
Post by Paul Moore
The subject says it all, two new MIPS ABIs, both in little and big
endian. I've tested the code on x86_64 and it looks reasonable, but
due to a lack of hardware I've been unable to do any actual MIPS
testing.
Markos, you said you would be able to verify the different MIPS ABIs,
could you test this code for us please?
-Paul
Hi Paul,
Thanks for the patch. I will give it a go next week.
Great, thank you.
--
paul moore
security and virtualization @ redhat
Markos Chandras
2014-08-26 09:34:49 UTC
Permalink
Post by Paul Moore
Post by Markos Chandras
Post by Paul Moore
The subject says it all, two new MIPS ABIs, both in little and big
endian. I've tested the code on x86_64 and it looks reasonable, but
due to a lack of hardware I've been unable to do any actual MIPS
testing.
Markos, you said you would be able to verify the different MIPS ABIs,
could you test this code for us please?
-Paul
Hi Paul,
Thanks for the patch. I will give it a go next week.
Great, thank you.
Hi Paul,

I tried b2adeeeeb00a23ed70df7f500add469e46d25400 on mips64/BE/n64 and
mips64/BE/n32 and both simulator and live tests pass with v3.17-rc1.
Thank you for your work. Testing mips64/LE will take a while but the
fact that BE works it's a really good sign for me.
--
markos
Paul Moore
2014-08-26 18:44:14 UTC
Permalink
Post by Markos Chandras
Post by Paul Moore
Post by Markos Chandras
Post by Paul Moore
The subject says it all, two new MIPS ABIs, both in little and big
endian. I've tested the code on x86_64 and it looks reasonable, but
due to a lack of hardware I've been unable to do any actual MIPS
testing.
Markos, you said you would be able to verify the different MIPS ABIs,
could you test this code for us please?
-Paul
Hi Paul,
Thanks for the patch. I will give it a go next week.
Great, thank you.
Hi Paul,
I tried b2adeeeeb00a23ed70df7f500add469e46d25400 on mips64/BE/n64 and
mips64/BE/n32 and both simulator and live tests pass with v3.17-rc1.
Thank you for your work. Testing mips64/LE will take a while but the
fact that BE works it's a really good sign for me.
That's great news, thanks for your help with testing. Please let me know once
you've had a chance to test the little endian versions of the ABIs.

-Paul
--
paul moore
security and virtualization @ redhat
Marcin Juszkiewicz
2014-08-21 09:15:43 UTC
Permalink
MIPS stuff needs to be handled on MIPS platforms otherwise no new
architectures can be added after MIPS block.

---
src/arch.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/arch.c b/src/arch.c
index 1e61db3..c65497b 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -50,19 +50,19 @@ const struct arch_def *arch_def_native = &arch_def_x86_64;
#endif /* __ILP32__ */
#elif __arm__
const struct arch_def *arch_def_native = &arch_def_arm;
-#elif _MIPS_SIM == _MIPS_SIM_ABI32
+#elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI32
#if __MIPSEB__
const struct arch_def *arch_def_native = &arch_def_mips;
#elif __MIPSEL__
const struct arch_def *arch_def_native = &arch_def_mipsel;
#endif /* _MIPS_SIM_ABI32 */
-#elif _MIPS_SIM == _MIPS_SIM_ABI64
+#elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI64
#if __MIPSEB__
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
+#elif __mips__ && _MIPS_SIM == _MIPS_SIM_NABI32
#if __MIPSEB__
const struct arch_def *arch_def_native = &arch_def_mips64n32;
#elif __MIPSEL__
--
2.1.0
Marcin Juszkiewicz
2014-08-21 09:15:43 UTC
Permalink
MIPS stuff needs to be handled on MIPS platforms otherwise no new
architectures can be added after MIPS block.

Signed-off-by: Marcin Juszkiewicz <***@redhat.com>

---
src/arch.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/arch.c b/src/arch.c
index 1e61db3..c65497b 100644
--- a/src/arch.c
+++ b/src/arch.c
@@ -50,19 +50,19 @@ const struct arch_def *arch_def_native = &arch_def_x86_64;
#endif /* __ILP32__ */
#elif __arm__
const struct arch_def *arch_def_native = &arch_def_arm;
-#elif _MIPS_SIM == _MIPS_SIM_ABI32
+#elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI32
#if __MIPSEB__
const struct arch_def *arch_def_native = &arch_def_mips;
#elif __MIPSEL__
const struct arch_def *arch_def_native = &arch_def_mipsel;
#endif /* _MIPS_SIM_ABI32 */
-#elif _MIPS_SIM == _MIPS_SIM_ABI64
+#elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI64
#if __MIPSEB__
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
+#elif __mips__ && _MIPS_SIM == _MIPS_SIM_NABI32
#if __MIPSEB__
const struct arch_def *arch_def_native = &arch_def_mips64n32;
#elif __MIPSEL__
-- 2.1.0
Loading...