jail: respect byte order when setting AUDIT_ARCH
authorDaniel Golle <daniel@makrotopia.org>
Sun, 17 May 2015 02:33:29 +0000 (04:33 +0200)
committerJohn Crispin <blogic@openwrt.org>
Thu, 14 May 2015 03:23:30 +0000 (05:23 +0200)
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>
jail/seccomp-bpf.h

index 40fe7b9c4fa8ba3af5ebdb549b84ac4674c6ebf3..82c06691e477127f73511b0d34e6df751e03cf52 100644 (file)
@@ -20,6 +20,7 @@
 #include <signal.h>
 #include <string.h>
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
 #include <unistd.h>
+#include <endian.h>
 
 #include <sys/prctl.h>
 #ifndef PR_SET_NO_NEW_PRIVS
 
 #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_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]
 #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
 #else
 # warning "Platform does not support seccomp filter yet"
 # define REG_SYSCALL   0