Skip to content

Commit 37989de

Browse files
committed
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>
1 parent 0dd7d68 commit 37989de

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,9 +1756,19 @@ TEST_F(TRACE_poke, getpid_runs_normally)
17561756
# define SYSCALL_RET(_regs) (_regs).gprs[2]
17571757
# define SYSCALL_NUM_RET_SHARE_REG
17581758
#elif defined(__mips__)
1759+
# include <asm/unistd_nr_n32.h>
1760+
# include <asm/unistd_nr_n64.h>
1761+
# include <asm/unistd_nr_o32.h>
17591762
# define ARCH_REGS struct pt_regs
1760-
# define SYSCALL_NUM(_regs) (_regs).regs[2]
1761-
# define SYSCALL_SYSCALL_NUM regs[4]
1763+
# define SYSCALL_NUM(_regs) \
1764+
({ \
1765+
typeof((_regs).regs[2]) _nr; \
1766+
if ((_regs).regs[2] == __NR_O32_Linux) \
1767+
_nr = (_regs).regs[4]; \
1768+
else \
1769+
_nr = (_regs).regs[2]; \
1770+
_nr; \
1771+
})
17621772
# define SYSCALL_NUM_SET(_regs, _nr) \
17631773
do { \
17641774
if ((_regs).regs[2] == __NR_O32_Linux) \
@@ -1838,10 +1848,6 @@ int get_syscall(struct __test_metadata *_metadata, pid_t tracee)
18381848
}
18391849
#endif
18401850

1841-
#if defined(__mips__)
1842-
if (SYSCALL_NUM(regs) == __NR_O32_Linux)
1843-
return regs.SYSCALL_SYSCALL_NUM;
1844-
#endif
18451851
return SYSCALL_NUM(regs);
18461852
}
18471853

0 commit comments

Comments
 (0)