diff options
author | Michael Ellerman <mpe@ellerman.id.au> | 2015-07-23 20:21:10 +1000 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2015-07-30 14:35:36 +1000 |
commit | a79c22c204e3d76c6c0269f814083c87b8e3887b (patch) | |
tree | 54bb348144a977e2ff22f03c719f6b9cf03e7f00 | |
parent | c86bc1cebde9292ddd171f7436f47e25e2a52c0a (diff) | |
download | platform_external_seccomp-tests-a79c22c204e3d76c6c0269f814083c87b8e3887b.tar.gz platform_external_seccomp-tests-a79c22c204e3d76c6c0269f814083c87b8e3887b.tar.bz2 platform_external_seccomp-tests-a79c22c204e3d76c6c0269f814083c87b8e3887b.zip |
selftests/seccomp: Make seccomp tests work on big endian
The seccomp_bpf test uses BPF_LD|BPF_W|BPF_ABS to load 32-bit values
from seccomp_data->args. On big endian machines this will load the high
word of the argument, which is not what the test wants.
Borrow a hack from samples/seccomp/bpf-helper.h which changes the offset
on big endian to account for this.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Kees Cook <keescook@chromium.org>
-rw-r--r-- | seccomp_bpf.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/seccomp_bpf.c b/seccomp_bpf.c index c5abe7f..2303a8d 100644 --- a/seccomp_bpf.c +++ b/seccomp_bpf.c @@ -82,7 +82,13 @@ struct seccomp_data { }; #endif +#if __BYTE_ORDER == __LITTLE_ENDIAN #define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n])) +#elif __BYTE_ORDER == __BIG_ENDIAN +#define syscall_arg(_n) (offsetof(struct seccomp_data, args[_n]) + sizeof(__u32)) +#else +#error "wut? Unknown __BYTE_ORDER?!" +#endif #define SIBLING_EXIT_UNKILLED 0xbadbeef #define SIBLING_EXIT_FAILURE 0xbadface |