From patchwork Sun May 17 02:33:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 473110 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9C41014077A for ; Sun, 17 May 2015 12:34:47 +1000 (AEST) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 681962848A9; Sun, 17 May 2015 04:32:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 16DEE284314 for ; Sun, 17 May 2015 04:32:12 +0200 (CEST) X-policyd-weight: using cached result; rate:hard: -7.6 Received: from fudo.makrotopia.org (fudo.makrotopia.org [5.135.190.93]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Sun, 17 May 2015 04:32:12 +0200 (CEST) Received: from local by fudo.makrotopia.org with esmtpsa (TLSv1.2:AES128-GCM-SHA256:128) (Exim 4.84) (envelope-from ) id 1YtoOQ-0004Ok-JI; Sun, 17 May 2015 04:33:30 +0200 Date: Sun, 17 May 2015 04:33:29 +0200 From: Daniel Golle To: openwrt-devel@lists.openwrt.org Message-ID: <20150517023323.GA3440@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Subject: [OpenWrt-Devel] [PATCH 3/3] jail: respect byte order when setting AUDIT_ARCH X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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 --- jail/seccomp-bpf.h | 13 +++++++++++-- 1 file 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 #include #include +#include #include #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