MIPS: Compat: Use 32-bit wrapper for compat_sys_futex.
authorYong Zhang <yong.zhang@windriver.com>
Tue, 16 Aug 2011 01:54:54 +0000 (09:54 +0800)
committerRalf Baechle <ralf@linux-mips.org>
Wed, 21 Sep 2011 15:53:44 +0000 (17:53 +0200)
We can't trust userspace to pass signed-extend arguments.  Not correctly
sign-extended arguments to futex-wait result in architecturally undefined
operation of 32-bit arithmetic instructions.

For example, if 'val' is too big and bit-31 is 1, the caller may enter
endless loop at:

futex_wait_setup()
{
...

if (uval != val) {
queue_unlock(q, *hb);
ret = -EWOULDBLOCK;

...
}

Signed-off-by: Yong Zhang <yong.zhang@windriver.com>
To: linux-mips@linux-mips.org
To: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/2714/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/linux32.c
arch/mips/kernel/scall64-n32.S
arch/mips/kernel/scall64-o32.S

index 876a75c..922a554 100644 (file)
@@ -349,3 +349,10 @@ SYSCALL_DEFINE6(32_fanotify_mark, int, fanotify_fd, unsigned int, flags,
        return sys_fanotify_mark(fanotify_fd, flags, merge_64(a3, a4),
                                 dfd, pathname);
 }
+
+SYSCALL_DEFINE6(32_futex, u32 __user *, uaddr, int, op, u32, val,
+               struct compat_timespec __user *, utime, u32 __user *, uaddr2,
+               u32, val3)
+{
+       return compat_sys_futex(uaddr, op, val, utime, uaddr2, val3);
+}
index f9296e8..6de1f59 100644 (file)
@@ -315,7 +315,7 @@ EXPORT(sysn32_call_table)
        PTR     sys_fremovexattr
        PTR     sys_tkill
        PTR     sys_ni_syscall
-       PTR     compat_sys_futex
+       PTR     sys_32_futex
        PTR     compat_sys_sched_setaffinity    /* 6195 */
        PTR     compat_sys_sched_getaffinity
        PTR     sys_cacheflush
index 4d7c982..1d81316 100644 (file)
@@ -441,7 +441,7 @@ sys_call_table:
        PTR     sys_fremovexattr                /* 4235 */
        PTR     sys_tkill
        PTR     sys_sendfile64
-       PTR     compat_sys_futex
+       PTR     sys_32_futex
        PTR     compat_sys_sched_setaffinity
        PTR     compat_sys_sched_getaffinity    /* 4240 */
        PTR     compat_sys_io_setup