Commit 0dd7d685 authored by Kees Cook's avatar Kees Cook

selftests/seccomp: arm64: Define SYSCALL_NUM_SET macro

Remove the arm64 special-case in change_syscall().
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/lkml/20200912110820.597135-6-keescook@chromium.orgAcked-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
parent aa8fbb80
...@@ -1717,6 +1717,18 @@ TEST_F(TRACE_poke, getpid_runs_normally) ...@@ -1717,6 +1717,18 @@ TEST_F(TRACE_poke, getpid_runs_normally)
#elif defined(__aarch64__) #elif defined(__aarch64__)
# define ARCH_REGS struct user_pt_regs # define ARCH_REGS struct user_pt_regs
# define SYSCALL_NUM(_regs) (_regs).regs[8] # define SYSCALL_NUM(_regs) (_regs).regs[8]
# ifndef NT_ARM_SYSTEM_CALL
# define NT_ARM_SYSTEM_CALL 0x404
# endif
# define SYSCALL_NUM_SET(_regs, _nr) \
do { \
struct iovec __v; \
typeof(_nr) __nr = (_nr); \
__v.iov_base = &__nr; \
__v.iov_len = sizeof(__nr); \
EXPECT_EQ(0, ptrace(PTRACE_SETREGSET, tracee, \
NT_ARM_SYSTEM_CALL, &__v)); \
} while (0)
# define SYSCALL_RET(_regs) (_regs).regs[0] # define SYSCALL_RET(_regs) (_regs).regs[0]
#elif defined(__riscv) && __riscv_xlen == 64 #elif defined(__riscv) && __riscv_xlen == 64
# define ARCH_REGS struct user_regs_struct # define ARCH_REGS struct user_regs_struct
...@@ -1852,23 +1864,10 @@ void change_syscall(struct __test_metadata *_metadata, ...@@ -1852,23 +1864,10 @@ void change_syscall(struct __test_metadata *_metadata,
#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \ #if defined(__x86_64__) || defined(__i386__) || defined(__powerpc__) || \
defined(__s390__) || defined(__hppa__) || defined(__riscv) || \ defined(__s390__) || defined(__hppa__) || defined(__riscv) || \
defined(__xtensa__) || defined(__csky__) || defined(__sh__) || \ defined(__xtensa__) || defined(__csky__) || defined(__sh__) || \
defined(__mips__) || defined(__arm__) defined(__mips__) || defined(__arm__) || defined(__aarch64__)
{ {
SYSCALL_NUM_SET(regs, syscall); SYSCALL_NUM_SET(regs, syscall);
} }
#elif defined(__aarch64__)
# ifndef NT_ARM_SYSTEM_CALL
# define NT_ARM_SYSTEM_CALL 0x404
# endif
{
iov.iov_base = &syscall;
iov.iov_len = sizeof(syscall);
ret = ptrace(PTRACE_SETREGSET, tracee, NT_ARM_SYSTEM_CALL,
&iov);
EXPECT_EQ(0, ret);
}
#else #else
ASSERT_EQ(1, 0) { ASSERT_EQ(1, 0) {
TH_LOG("How is the syscall changed on this architecture?"); TH_LOG("How is the syscall changed on this architecture?");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment