aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel/scall32-o32.S
diff options
context:
space:
mode:
authorVlad Malov <Vlad.Malov@caviumnetworks.com>2008-11-18 18:05:46 -0500
committerRalf Baechle <ralf@linux-mips.org>2008-12-04 12:47:26 -0500
commite807f9574e37a3f202e677feaaad1b7c5d2c0db8 (patch)
treea9b61e4d8f4e53a81df3bb14df0a4c2b037d8d81 /arch/mips/kernel/scall32-o32.S
parentfeaf3848a813a106f163013af6fcf6c4bfec92d9 (diff)
MIPS: Fix potential DOS by untrusted user app.
On a 64 bit kernel if an o32 syscall was made with a syscall number less than 4000, we would read the function from outside of the bounds of the syscall table. This led to non-deterministic behavior including system crashes. While we were at it we reworked the 32 bit version as well to use fewer instructions. Both 32 and 64 bit versions are use the same code now. Signed-off-by: Vlad Malov <Vlad.Malov@caviumnetworks.com> Signed-off-by: David Daney <ddaney@caviumnetworks.com> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/scall32-o32.S')
-rw-r--r--arch/mips/kernel/scall32-o32.S5
1 files changed, 1 insertions, 4 deletions
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 759f68066b5d..34a4dbd76f24 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -262,14 +262,11 @@ bad_alignment:
262 LEAF(sys_syscall) 262 LEAF(sys_syscall)
263 subu t0, a0, __NR_O32_Linux # check syscall number 263 subu t0, a0, __NR_O32_Linux # check syscall number
264 sltiu v0, t0, __NR_O32_Linux_syscalls + 1 264 sltiu v0, t0, __NR_O32_Linux_syscalls + 1
265 beqz t0, einval # do not recurse
265 sll t1, t0, 3 266 sll t1, t0, 3
266 beqz v0, einval 267 beqz v0, einval
267
268 lw t2, sys_call_table(t1) # syscall routine 268 lw t2, sys_call_table(t1) # syscall routine
269 269
270 li v1, 4000 - __NR_O32_Linux # index of sys_syscall
271 beq t0, v1, einval # do not recurse
272
273 /* Some syscalls like execve get their arguments from struct pt_regs 270 /* Some syscalls like execve get their arguments from struct pt_regs
274 and claim zero arguments in the syscall table. Thus we have to 271 and claim zero arguments in the syscall table. Thus we have to
275 assume the worst case and shuffle around all potential arguments. 272 assume the worst case and shuffle around all potential arguments.