Skip to content

Commit 0dd7d68

Browse files
committed
selftests/seccomp: arm64: Define SYSCALL_NUM_SET macro
Remove the arm64 special-case in change_syscall(). Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/lkml/20200912110820.597135-6-keescook@chromium.org Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
1 parent aa8fbb8 commit 0dd7d68

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

tools/testing/selftests/seccomp/seccomp_bpf.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,18 @@ TEST_F(TRACE_poke, getpid_runs_normally)
17171717
#elif defined(__aarch64__)
17181718
# define ARCH_REGS struct user_pt_regs
17191719
# define SYSCALL_NUM(_regs) (_regs).regs[8]
1720+
# ifndef NT_ARM_SYSTEM_CALL
1721+
# define NT_ARM_SYSTEM_CALL 0x404
1722+
# endif
1723+
# define SYSCALL_NUM_SET(_regs, _nr) \
1724+
do { \
1725+
struct iovec __v; \
1726+
typeof(_nr) __nr = (_nr); \
1727+
__v.iov_base = &__nr; \
1728+
__v.iov_len = sizeof(__nr); \
1729+
EXPECT_EQ(0, ptrace(PTRACE_SETREGSET, tracee, \
1730+
NT_ARM_SYSTEM_CALL, &__v)); \
1731+
} while (0)
17201732
# define SYSCALL_RET(_regs) (_regs).regs[0]
17211733
#elif defined(__riscv) && __riscv_xlen == 64
17221734
# define ARCH_REGS struct user_regs_struct
@@ -1852,23 +1864,10 @@ void change_syscall(struct __test_metadata *_metadata,
18521864
#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
18531865
defined(__s390__) || defined(__hppa__) || defined(__riscv) || \
18541866
defined(__xtensa__) || defined(__csky__) || defined(__sh__) || \
1855-
defined(__mips__) || defined(__arm__)
1867+
defined(__mips__) || defined(__arm__) || defined(__aarch64__)
18561868
{
18571869
SYSCALL_NUM_SET(regs, syscall);
18581870
}
1859-
1860-
#elif defined(__aarch64__)
1861-
# ifndef NT_ARM_SYSTEM_CALL
1862-
# define NT_ARM_SYSTEM_CALL 0x404
1863-
# endif
1864-
{
1865-
iov.iov_base = &syscall;
1866-
iov.iov_len = sizeof(syscall);
1867-
ret = ptrace(PTRACE_SETREGSET, tracee, NT_ARM_SYSTEM_CALL,
1868-
&iov);
1869-
EXPECT_EQ(0, ret);
1870-
}
1871-
18721871
#else
18731872
ASSERT_EQ(1, 0) {
18741873
TH_LOG("How is the syscall changed on this architecture?");

0 commit comments

Comments
 (0)