aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2014-07-24 07:10:02 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-08-25 20:18:56 -0400
commitad61ba23f192f6d87a4e1f665f2d92ba2bae0950 (patch)
treed9ac9b78413fc9867d824b109744a180bde72272
parent8d74ea0edb83a57f793a55bb7360a17af8ade5d1 (diff)
MIPS: scall64-o32: Fix indirect syscall detection
Commit 4c21b8fd8f14 (MIPS: seccomp: Handle indirect system calls (o32)) added indirect syscall detection for O32 processes running on MIPS64 but it did not work as expected. The reason is the the scall64-o32 implementation differs compared to scall32-o32. In the former, the v0 (syscall number) register contains the absolute syscall number (4000 + X) whereas in the latter it contains the relative syscall number (X). Fix the code to avoid doing an extra addition, and load the v0 register directly to the first argument for syscall_trace_enter. Moreover, set the .reorder assembler option in order to have better control on this part of the assembly code. Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Patchwork: http://patchwork.linux-mips.org/patch/7481/ Cc: <stable@vger.kernel.org> # v3.15+ Signed-off-by: James Hogan <james.hogan@imgtec.com>
-rw-r--r--arch/mips/kernel/scall64-o32.S12
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 13b964fddc4a..25bb8400156d 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -113,15 +113,19 @@ trace_a_syscall:
113 move s0, t2 # Save syscall pointer 113 move s0, t2 # Save syscall pointer
114 move a0, sp 114 move a0, sp
115 /* 115 /*
116 * syscall number is in v0 unless we called syscall(__NR_###) 116 * absolute syscall number is in v0 unless we called syscall(__NR_###)
117 * where the real syscall number is in a0 117 * where the real syscall number is in a0
118 * note: NR_syscall is the first O32 syscall but the macro is 118 * note: NR_syscall is the first O32 syscall but the macro is
119 * only defined when compiling with -mabi=32 (CONFIG_32BIT) 119 * only defined when compiling with -mabi=32 (CONFIG_32BIT)
120 * therefore __NR_O32_Linux is used (4000) 120 * therefore __NR_O32_Linux is used (4000)
121 */ 121 */
122 addiu a1, v0, __NR_O32_Linux 122 .set push
123 bnez v0, 1f /* __NR_syscall at offset 0 */ 123 .set reorder
124 lw a1, PT_R4(sp) 124 subu t1, v0, __NR_O32_Linux
125 move a1, v0
126 bnez t1, 1f /* __NR_syscall at offset 0 */
127 lw a1, PT_R4(sp) /* Arg1 for __NR_syscall case */
128 .set pop
125 129
1261: jal syscall_trace_enter 1301: jal syscall_trace_enter
127 131