Message ID | 1437646871-3195-11-git-send-email-mpe@ellerman.id.au (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Michael Ellerman |
Headers | show |
On Thu, Jul 23, 2015 at 3:21 AM, Michael Ellerman <mpe@ellerman.id.au> wrote: > Wire up the syscall number and regs so the tests work on powerpc. This patch begs the question: this passes everything? (I was reminded about syscall_restart while reading the patches. If everything passes, it looks like powerpc exposes syscall_restart? Seems like ARM remains the odd-arch-out on this. :P) Thanks! -Kees > > Acked-by: Kees Cook <keescook@chromium.org> > Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> > --- > tools/testing/selftests/seccomp/seccomp_bpf.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c > index 2303a8dff9a2..a004b4cce99e 100644 > --- a/tools/testing/selftests/seccomp/seccomp_bpf.c > +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c > @@ -14,6 +14,7 @@ > #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> > @@ -1205,6 +1206,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) > # define ARCH_REGS struct user_pt_regs > # define SYSCALL_NUM regs[8] > # define SYSCALL_RET regs[0] > +#elif defined(__powerpc__) > +# define ARCH_REGS struct pt_regs > +# define SYSCALL_NUM gpr[0] > +# define SYSCALL_RET gpr[3] > #else > # error "Do not know how to find your architecture's registers and syscalls" > #endif > @@ -1238,7 +1243,7 @@ void change_syscall(struct __test_metadata *_metadata, > ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); > EXPECT_EQ(0, ret); > > -#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) > +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) > { > regs.SYSCALL_NUM = syscall; > } > @@ -1402,6 +1407,8 @@ TEST_F(TRACE_syscall, syscall_dropped) > # define __NR_seccomp 383 > # elif defined(__aarch64__) > # define __NR_seccomp 277 > +# elif defined(__powerpc__) > +# define __NR_seccomp 358 > # else > # warning "seccomp syscall number unknown for this architecture" > # define __NR_seccomp 0xffff > -- > 2.1.0 >
On Mon, 2015-07-27 at 11:59 -0700, Kees Cook wrote: > On Thu, Jul 23, 2015 at 3:21 AM, Michael Ellerman <mpe@ellerman.id.au> wrote: > > Wire up the syscall number and regs so the tests work on powerpc. > > This patch begs the question: this passes everything? Doh, yes that would have been worth mentioning! :) I'll update it before I commit it. Yes everything passes, thanks very much for the tests BTW. And for the record I've tested on: ppc64, ppc64 (compat), ppc64le, ppc, ppc64e and ppc64e (compat). > (I was reminded about syscall_restart while reading the patches. If > everything passes, it looks like powerpc exposes syscall_restart? Seems like > ARM remains the odd-arch-out on this. :P) Yeah I noticed that and though "oh jeez not syscall_restart", but it seems to pass, so I guess we behave in a standard fasion for once. I'll have a closer look just to be sure before I merge. cheers
diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c index 2303a8dff9a2..a004b4cce99e 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -14,6 +14,7 @@ #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> @@ -1205,6 +1206,10 @@ TEST_F(TRACE_poke, getpid_runs_normally) # define ARCH_REGS struct user_pt_regs # define SYSCALL_NUM regs[8] # define SYSCALL_RET regs[0] +#elif defined(__powerpc__) +# define ARCH_REGS struct pt_regs +# define SYSCALL_NUM gpr[0] +# define SYSCALL_RET gpr[3] #else # error "Do not know how to find your architecture's registers and syscalls" #endif @@ -1238,7 +1243,7 @@ void change_syscall(struct __test_metadata *_metadata, ret = ptrace(PTRACE_GETREGSET, tracee, NT_PRSTATUS, &iov); EXPECT_EQ(0, ret); -#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) || defined(__powerpc__) { regs.SYSCALL_NUM = syscall; } @@ -1402,6 +1407,8 @@ TEST_F(TRACE_syscall, syscall_dropped) # define __NR_seccomp 383 # elif defined(__aarch64__) # define __NR_seccomp 277 +# elif defined(__powerpc__) +# define __NR_seccomp 358 # else # warning "seccomp syscall number unknown for this architecture" # define __NR_seccomp 0xffff