summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/seccomp
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2020-09-12 14:08:11 +0300
committerKees Cook <keescook@chromium.org>2020-09-19 10:59:45 +0300
commit37989de731dbea5af143806192c4cd1484990ab4 (patch)
tree4ebbda6a56abe96e242c3ee0a5b5c6dc1f81ed46 /tools/testing/selftests/seccomp
parent0dd7d68572d9393765b57c001adc30822e3003ed (diff)
downloadlinux-37989de731dbea5af143806192c4cd1484990ab4.tar.xz
selftests/seccomp: mips: Remove O32-specific macro
Instead of having the mips O32 macro special-cased, pull the logic into the SYSCALL_NUM() macro. Additionally include the ABI headers, since these appear to have been missing, leaving __NR_O32_Linux undefined. Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/lkml/20200912110820.597135-7-keescook@chromium.org Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Diffstat (limited to 'tools/testing/selftests/seccomp')
-rw-r--r--tools/testing/selftests/seccomp/seccomp_bpf.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index ef7f65468069..7976cb480912 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/seccomp_bpf.c
@@ -1756,9 +1756,19 @@ TEST_F(TRACE_poke, getpid_runs_normally)
# define SYSCALL_RET(_regs) (_regs).gprs[2]
# define SYSCALL_NUM_RET_SHARE_REG
#elif defined(__mips__)
+# include <asm/unistd_nr_n32.h>
+# include <asm/unistd_nr_n64.h>
+# include <asm/unistd_nr_o32.h>
# define ARCH_REGS struct pt_regs
-# define SYSCALL_NUM(_regs) (_regs).regs[2]
-# define SYSCALL_SYSCALL_NUM regs[4]
+# define SYSCALL_NUM(_regs) \
+ ({ \
+ typeof((_regs).regs[2]) _nr; \
+ if ((_regs).regs[2] == __NR_O32_Linux) \
+ _nr = (_regs).regs[4]; \
+ else \
+ _nr = (_regs).regs[2]; \
+ _nr; \
+ })
# define SYSCALL_NUM_SET(_regs, _nr) \
do { \
if ((_regs).regs[2] == __NR_O32_Linux) \
@@ -1838,10 +1848,6 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
}
#endif
-#if defined(__mips__)
- if (SYSCALL_NUM(regs) == __NR_O32_Linux)
- return regs.SYSCALL_SYSCALL_NUM;
-#endif
return SYSCALL_NUM(regs);
}