arm: add bounds check on hypercall array
authorIan Campbell <ian.campbell@citrix.com>
Wed, 25 Jul 2012 16:39:21 +0000 (17:39 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 25 Jul 2012 16:39:21 +0000 (17:39 +0100)
Otherwise a guest can cause us to run off the end of the array.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
[ ijc -- switched to >= not > ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/traps.c

index f2c25b582149be9f0a889580ff3bef59d824c266..d2adf4fee14caa85737a3e6f15ea38f566870722 100644 (file)
@@ -479,6 +479,12 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, unsigned long iss)
         return;
     }
 
+    if ( regs->r12 >= ARRAY_SIZE(arm_hypercall_table) )
+    {
+        regs->r0 = -ENOSYS;
+        return;
+    }
+
     call = arm_hypercall_table[regs->r12].fn;
     if ( call == NULL )
     {