]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
linux-user: Range check the nfds argument to ppoll syscall
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 18 Jul 2016 15:30:36 +0000 (16:30 +0100)
committerRiku Voipio <riku.voipio@linaro.org>
Wed, 21 Sep 2016 11:25:53 +0000 (14:25 +0300)
Do an initial range check on the ppoll syscall's nfds argument,
to avoid possible overflow in the calculation of the lock_user()
size argument. The host kernel will later apply the rather lower
limit based on RLIMIT_NOFILE as appropriate.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c

index eecccbb25c516fd342d4ca1bd0b3755bd9a45023..7a50a57d4bfd1e5643ddf063a0324409149bc00c 100644 (file)
@@ -9661,6 +9661,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             pfd = NULL;
             target_pfd = NULL;
             if (nfds) {
+                if (nfds > (INT_MAX / sizeof(struct target_pollfd))) {
+                    ret = -TARGET_EINVAL;
+                    break;
+                }
+
                 target_pfd = lock_user(VERIFY_WRITE, arg1,
                                        sizeof(struct target_pollfd) * nfds, 1);
                 if (!target_pfd) {