linux-mips
[Top] [All Lists]

[PATCH 6/8] MIPS: kernel: scalls: Skip the syscall if denied by the secc

To: <linux-mips@linux-mips.org>
Subject: [PATCH 6/8] MIPS: kernel: scalls: Skip the syscall if denied by the seccomp filter
From: Markos Chandras <markos.chandras@imgtec.com>
Date: Wed, 22 Jan 2014 14:40:02 +0000
Cc: Markos Chandras <markos.chandras@imgtec.com>
In-reply-to: <1390401604-11830-1-git-send-email-markos.chandras@imgtec.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1390401604-11830-1-git-send-email-markos.chandras@imgtec.com>
Sender: linux-mips-bounce@linux-mips.org
Reviewed-by: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
---
 arch/mips/kernel/scall32-o32.S | 4 +++-
 arch/mips/kernel/scall64-64.S  | 4 +++-
 arch/mips/kernel/scall64-n32.S | 4 +++-
 arch/mips/kernel/scall64-o32.S | 4 +++-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index e8e541b..ce6a1cc 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -120,6 +120,8 @@ syscall_trace_entry:
        move    a0, sp
        jal     syscall_trace_enter
 
+       bltz    v0, 2f                  # seccomp failed? Skip syscall
+
        move    t0, s0
        RESTORE_STATIC
        lw      a0, PT_R4(sp)           # Restore argument registers
@@ -138,7 +140,7 @@ syscall_trace_entry:
        sw      t1, PT_R0(sp)           # save it for syscall restarting
 1:     sw      v0, PT_R2(sp)           # result
 
-       j       syscall_exit
+2:     j       syscall_exit
 
 /* ------------------------------------------------------------------------ */
 
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 57e3742..88372a1 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -82,6 +82,8 @@ syscall_trace_entry:
        move    a0, sp
        jal     syscall_trace_enter
 
+       bltz    v0, 2f                  # seccomp failed? Skip syscall
+
        move    t0, s0
        RESTORE_STATIC
        ld      a0, PT_R4(sp)           # Restore argument registers
@@ -102,7 +104,7 @@ syscall_trace_entry:
        sd      t1, PT_R0(sp)           # save it for syscall restarting
 1:     sd      v0, PT_R2(sp)           # result
 
-       j       syscall_exit
+2:     j       syscall_exit
 
 illegal_syscall:
        /* This also isn't a 64-bit syscall, throw an error.  */
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 2f48f59..d79d880 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -74,6 +74,8 @@ n32_syscall_trace_entry:
        move    a0, sp
        jal     syscall_trace_enter
 
+       bltz    v0, 2f                  # seccomp failed? Skip syscall
+
        move    t0, s0
        RESTORE_STATIC
        ld      a0, PT_R4(sp)           # Restore argument registers
@@ -94,7 +96,7 @@ n32_syscall_trace_entry:
        sd      t1, PT_R0(sp)           # save it for syscall restarting
 1:     sd      v0, PT_R2(sp)           # result
 
-       j       syscall_exit
+2:     j       syscall_exit
 
 not_n32_scall:
        /* This is not an n32 compatibility syscall, pass it on to
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index f1acdb4..375a72b 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -114,6 +114,8 @@ trace_a_syscall:
        move    a0, sp
        jal     syscall_trace_enter
 
+       bltz    v0, 2f                  # seccomp failed? Skip syscall
+
        move    t0, s0
        RESTORE_STATIC
        ld      a0, PT_R4(sp)           # Restore argument registers
@@ -136,7 +138,7 @@ trace_a_syscall:
        sd      t1, PT_R0(sp)           # save it for syscall restarting
 1:     sd      v0, PT_R2(sp)           # result
 
-       j       syscall_exit
+2:     j       syscall_exit
 
 /* ------------------------------------------------------------------------ */
 
-- 
1.8.5.3



<Prev in Thread] Current Thread [Next in Thread>