summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2015-05-17 04:33:29 +0200
committerJohn Crispin <blogic@openwrt.org>2015-05-14 05:23:30 +0200
commit4574087e5ab6e5bb2758b4da85d0916ff5bd2329 (patch)
tree6a2d04ca9d96e4329224eff61776003ef59166c1
parent91f0891f7e2641330305f16d4738c4fb064c7449 (diff)
downloadunitd-4574087e5ab6e5bb2758b4da85d0916ff5bd2329.tar
unitd-4574087e5ab6e5bb2758b4da85d0916ff5bd2329.zip
jail: respect byte order when setting AUDIT_ARCH
AUDIT_ARCH on ARM and MIPS differs depending on the byte order. Thus set AUDIT_ARCH to the respective endian-specific variants. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--jail/seccomp-bpf.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/jail/seccomp-bpf.h b/jail/seccomp-bpf.h
index 40fe7b9..82c0669 100644
--- a/jail/seccomp-bpf.h
+++ b/jail/seccomp-bpf.h
@@ -20,6 +20,7 @@
#include <signal.h>
#include <string.h>
#include <unistd.h>
+#include <endian.h>
#include <sys/prctl.h>
#ifndef PR_SET_NO_NEW_PRIVS
@@ -67,10 +68,18 @@ struct seccomp_data {
# define ARCH_NR AUDIT_ARCH_X86_64
#elif defined(__mips__)
# define REG_SYSCALL regs[2]
-# define ARCH_NR AUDIT_ARCH_MIPSEL
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ARCH_NR AUDIT_ARCH_MIPSEL
+# else
+# define ARCH_NR AUDIT_ARCH_MIPS
+# endif
#elif defined(__arm__) && (defined(__ARM_EABI__) || defined(__thumb__))
# define REG_SYSCALL regs.uregs[7]
-# define ARCH_NR AUDIT_ARCH_ARM
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define ARCH_NR AUDIT_ARCH_ARM
+# else
+# define ARCH_NR AUDIT_ARCH_ARMEB
+# endif
#else
# warning "Platform does not support seccomp filter yet"
# define REG_SYSCALL 0