Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1184388

[RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian

From Michael Ellerman <mpe@ellerman.id.au>
Newsgroups linux.kernel
Subject [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian
Date 2015-07-15 09:40 +0200
Message-ID <pMpsm-LG-31@gated-at.bofh.it> (permalink)
References <pMpsl-LG-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testing/selftests/seccomp/seccomp_bpf.c
index b2374c131340..51adb9afb511 100644
--- a/tools/testing/selftests/seccomp/seccomp_bpf.c
+++ b/tools/testing/selftests/seccomp/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?"
+#endif
 
 #define SIBLING_EXIT_UNKILLED	0xbadbeef
 #define SIBLING_EXIT_FAILURE	0xbadface
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before calling do_syscall_trace_enter() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
  [RFC PATCH 03/12] powerpc/kernel: Change the do_syscall_trace_enter() API Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
  [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on big endian Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
    Re: [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on  big endian Kees Cook <keescook@chromium.org> - 2015-07-15 17:20 +0200
      Re: [RFC PATCH 11/12] selftests/seccomp: Make seccomp tests work on  big endian Michael Ellerman <mpe@ellerman.id.au> - 2015-07-16 05:50 +0200
  [RFC PATCH 04/12] powerpc: Drop unused syscall_get_error() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
  [RFC PATCH 07/12] powerpc: Use orig_gpr3 in syscall_get_arguments() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:40 +0200
  [RFC PATCH 02/12] powerpc/kernel: Switch to using MAX_ERRNO Michael Ellerman <mpe@ellerman.id.au> - 2015-07-15 09:50 +0200
    Re: [RFC PATCH 02/12] powerpc/kernel: Switch to using MAX_ERRNO Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-07-17 00:50 +0200
  Re: [RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before  calling do_syscall_trace_enter() Benjamin Herrenschmidt <benh@kernel.crashing.org> - 2015-07-17 00:50 +0200
    Re: [RFC PATCH 01/12] powerpc/kernel: Get pt_regs from r9 before  calling do_syscall_trace_enter() Michael Ellerman <mpe@ellerman.id.au> - 2015-07-17 06:50 +0200

csiph-web