summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorPeter Maydell2016-07-18 17:30:36 +0200
committerRiku Voipio2016-09-21 13:25:53 +0200
commitce9c139d93db03e464341385976606b7568b768f (patch)
treef948812bc2eac2e2da2258b94a0461e0970059ea /linux-user/syscall.c
parentlinux-user: Check for bad event numbers in epoll_wait (diff)
downloadqemu-ce9c139d93db03e464341385976606b7568b768f.tar.gz
qemu-ce9c139d93db03e464341385976606b7568b768f.tar.xz
qemu-ce9c139d93db03e464341385976606b7568b768f.zip
linux-user: Range check the nfds argument to ppoll syscall
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>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index eecccbb25c..7a50a57d4b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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) {