summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arch-mips.c53
-rw-r--r--tests/38-basic-pfc_coverage.pfc28
2 files changed, 61 insertions, 20 deletions
diff --git a/src/arch-mips.c b/src/arch-mips.c
index 2625ddc..7cc425a 100644
--- a/src/arch-mips.c
+++ b/src/arch-mips.c
@@ -30,9 +30,50 @@
#include "arch.h"
#include "arch-mips.h"
+/* O32 ABI */
+#define __SCMP_NR_BASE 4000
+
/* mips syscall numbers */
-#define __mips_NR_socketcall 102
-#define __mips_NR_ipc 117
+#define __mips_NR_socketcall (__SCMP_NR_BASE + 102)
+#define __mips_NR_ipc (__SCMP_NR_BASE + 117)
+
+/**
+ * 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 mips_syscall_resolve_name_raw(const char *name)
+{
+ int sys;
+
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ sys = mips_syscall_resolve_name(name);
+ if (sys == __NR_SCMP_ERROR || sys < 0)
+ return sys;
+
+ return sys + __SCMP_NR_BASE;
+}
+
+/**
+ * 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 *mips_syscall_resolve_num_raw(int num)
+{
+ /* NOTE: we don't want to modify the pseudo-syscall numbers */
+ if (num >= __SCMP_NR_BASE)
+ num -= __SCMP_NR_BASE;
+ return mips_syscall_resolve_num(num);
+}
const struct arch_def arch_def_mips = {
.token = SCMP_ARCH_MIPS,
@@ -42,9 +83,9 @@ const struct arch_def arch_def_mips = {
.sys_socketcall = __mips_NR_socketcall,
.sys_ipc = __mips_NR_ipc,
.syscall_resolve_name = abi_syscall_resolve_name_munge,
- .syscall_resolve_name_raw = mips_syscall_resolve_name,
+ .syscall_resolve_name_raw = mips_syscall_resolve_name_raw,
.syscall_resolve_num = abi_syscall_resolve_num_munge,
- .syscall_resolve_num_raw = mips_syscall_resolve_num,
+ .syscall_resolve_num_raw = mips_syscall_resolve_num_raw,
.syscall_rewrite = abi_syscall_rewrite,
.rule_add = abi_rule_add,
};
@@ -57,9 +98,9 @@ const struct arch_def arch_def_mipsel = {
.sys_socketcall = __mips_NR_socketcall,
.sys_ipc = __mips_NR_ipc,
.syscall_resolve_name = abi_syscall_resolve_name_munge,
- .syscall_resolve_name_raw = mips_syscall_resolve_name,
+ .syscall_resolve_name_raw = mips_syscall_resolve_name_raw,
.syscall_resolve_num = abi_syscall_resolve_num_munge,
- .syscall_resolve_num_raw = mips_syscall_resolve_num,
+ .syscall_resolve_num_raw = mips_syscall_resolve_num_raw,
.syscall_rewrite = abi_syscall_rewrite,
.rule_add = abi_rule_add,
};
diff --git a/tests/38-basic-pfc_coverage.pfc b/tests/38-basic-pfc_coverage.pfc
index 450401f..c91f1a8 100644
--- a/tests/38-basic-pfc_coverage.pfc
+++ b/tests/38-basic-pfc_coverage.pfc
@@ -302,23 +302,23 @@ if ($arch == 3221225655)
action ALLOW;
# filter for arch mipsel (1073741832)
if ($arch == 1073741832)
- # filter for syscall "exit_group" (246) [priority: 65535]
- if ($syscall == 246)
+ # filter for syscall "exit_group" (4246) [priority: 65535]
+ if ($syscall == 4246)
action LOG;
- # filter for syscall "fstat" (108) [priority: 65535]
- if ($syscall == 108)
+ # filter for syscall "fstat" (4108) [priority: 65535]
+ if ($syscall == 4108)
action KILL_PROCESS;
- # filter for syscall "close" (6) [priority: 65535]
- if ($syscall == 6)
+ # filter for syscall "close" (4006) [priority: 65535]
+ if ($syscall == 4006)
action ERRNO(1);
- # filter for syscall "open" (5) [priority: 65535]
- if ($syscall == 5)
+ # filter for syscall "open" (4005) [priority: 65535]
+ if ($syscall == 4005)
action KILL;
- # filter for syscall "exit" (1) [priority: 65535]
- if ($syscall == 1)
+ # filter for syscall "exit" (4001) [priority: 65535]
+ if ($syscall == 4001)
action TRACE(1);
- # filter for syscall "write" (4) [priority: 65532]
- if ($syscall == 4)
+ # filter for syscall "write" (4004) [priority: 65532]
+ if ($syscall == 4004)
if ($a0 == 0)
else
if ($a1 > 1)
@@ -326,8 +326,8 @@ if ($arch == 1073741832)
if ($a2 >= 2)
else
action TRAP;
- # filter for syscall "read" (3) [priority: 65531]
- if ($syscall == 3)
+ # filter for syscall "read" (4003) [priority: 65531]
+ if ($syscall == 4003)
if ($a0 == 0)
if ($a1 >= 1)
if ($a2 > 2)