Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1349718

[RFC][PATCH] selftests/seccomp: add MIPS self-test support

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject [RFC][PATCH] selftests/seccomp: add MIPS self-test support
Date 2016-03-04 01:10 +0100
Message-ID <r8LtD-6DX-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


This adds self-test support on MIPS. (On at least Bionic, the siginfo
headers require pid_t and clock_t to be defined first, so this meant
moving the sys/types.h include to before siginfo.h.)

Signed-off-by: Kees Cook <keescook@chromium.org>
---
I don't have hardware at the moment to test this. Can someone check this?
It's based on my best guess about the syscall ABI (v0 for syscall and
return value, which is regs[2]).
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index b9453b838162..bf59558fd50d 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -5,6 +5,7 @@
  * Test code for seccomp bpf.
  */
 
+#include <sys/types.h>
 #include <asm/siginfo.h>
 #define __have_siginfo_t 1
 #define __have_sigval_t 1
@@ -14,7 +15,6 @@
 #include <linux/filter.h>
 #include <sys/prctl.h>
 #include <sys/ptrace.h>
-#include <sys/types.h>
 #include <sys/user.h>
 #include <linux/prctl.h>
 #include <linux/ptrace.h>
@@ -1242,6 +1242,10 @@ TEST_F(TRACE_poke, getpid_runs_normally)
 # define ARCH_REGS     s390_regs
 # define SYSCALL_NUM   gprs[2]
 # define SYSCALL_RET   gprs[2]
+#elif defined(__mips__)
+# define ARCH_REGS	struct pt_regs
+# define SYSCALL_NUM	regs[2]
+# define SYSCALL_RET	regs[2]
 #else
 # error "Do not know how to find your architecture's registers and syscalls"
 #endif
@@ -1293,7 +1297,7 @@ void change_syscall(struct __test_metadata *_metadata,
 	EXPECT_EQ(0, ret);
 
 #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
-    defined(__s390__)
+    defined(__s390__) || defined(__mips__)
 	{
 		regs.SYSCALL_NUM = syscall;
 	}
-- 
2.6.3


-- 
Kees Cook
Chrome OS & Brillo Security

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[RFC][PATCH] selftests/seccomp: add MIPS self-test support Kees Cook <keescook@chromium.org> - 2016-03-04 01:10 +0100

csiph-web