Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1209)

Unified Diff: sandbox/linux/seccomp-bpf/syscall_unittest.cc

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf/syscall_unittest.cc
diff --git a/sandbox/linux/seccomp-bpf/syscall_unittest.cc b/sandbox/linux/seccomp-bpf/syscall_unittest.cc
index 60db69bcd6bb5388bb8929740fdef48156cba5ed..0cdd767252c467dee50bbcebb06fb5a7a1f23ecc 100644
--- a/sandbox/linux/seccomp-bpf/syscall_unittest.cc
+++ b/sandbox/linux/seccomp-bpf/syscall_unittest.cc
@@ -50,6 +50,9 @@ TEST(Syscall, WellKnownEntryPoint) {
#else
EXPECT_EQ(0xEF000000u, ((uint32_t*)SandboxSyscall(-1))[-1]); // SVC 0
#endif
+#elif defined(__mips__)
+ // Opcode for MIPS sycall is in the lower 16-bits
+ EXPECT_EQ(0x0cu, (((uint32_t *)SandboxSyscall(-1))[-1])&0x0000FFFF);
#else
#warning Incomplete test case; need port for target platform
#endif
@@ -75,7 +78,12 @@ intptr_t CopySyscallArgsToAux(const struct arch_seccomp_data& args, void* aux) {
static_cast<std::vector<uint64_t>*>(aux);
BPF_ASSERT(arraysize(args.args) == 6);
seen_syscall_args->assign(args.args, args.args + arraysize(args.args));
+#if defined(__mips__)
+ // On MIPS, kernel returns errno and not -errno
+ return ENOMEM;
+#else
return -ENOMEM;
+#endif
}
ErrorCode CopyAllArgsOnUnamePolicy(SandboxBPF* sandbox, int sysno, void* aux) {
@@ -107,6 +115,15 @@ BPF_TEST(Syscall,
// We could use pretty much any system call we don't need here. uname() is
// nice because it doesn't have any dangerous side effects.
+#if defined(__mips__)
+ BPF_ASSERT(SandboxSyscall(__NR_uname,
+ syscall_args[0],
+ syscall_args[1],
+ syscall_args[2],
+ syscall_args[3],
+ syscall_args[4],
+ syscall_args[5]) == ENOMEM);
+#else
BPF_ASSERT(SandboxSyscall(__NR_uname,
syscall_args[0],
syscall_args[1],
@@ -114,6 +131,7 @@ BPF_TEST(Syscall,
syscall_args[3],
syscall_args[4],
syscall_args[5]) == -ENOMEM);
+#endif
// We expect the trap handler to have copied the 6 arguments.
BPF_ASSERT(BPF_AUX.size() == 6);

Powered by Google App Engine
This is Rietveld 408576698