summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorPeter Maydell2016-07-18 16:35:59 +0200
committerRiku Voipio2016-09-21 13:25:26 +0200
commit2ba7fae3bd688f5bb6cb08defc731d77e6bd943c (patch)
treea2138d834c2f9d056db7c55b26118b554865be46 /linux-user/syscall.c
parentlinux-user: Use direct syscall for utimensat (diff)
downloadqemu-2ba7fae3bd688f5bb6cb08defc731d77e6bd943c.tar.gz
qemu-2ba7fae3bd688f5bb6cb08defc731d77e6bd943c.tar.xz
qemu-2ba7fae3bd688f5bb6cb08defc731d77e6bd943c.zip
linux-user: Check for bad event numbers in epoll_wait
The kernel checks that the maxevents parameter to epoll_wait is non-negative and not larger than EP_MAX_EVENTS. Add this check to our implementation, so that: * we fail these cases EINVAL rather than EFAULT * we don't pass negative or overflowing values to the lock_user() size calculation 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 21ae996dd1..eecccbb25c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11501,6 +11501,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
int maxevents = arg3;
int timeout = arg4;
+ if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
+ ret = -TARGET_EINVAL;
+ break;
+ }
+
target_ep = lock_user(VERIFY_WRITE, arg2,
maxevents * sizeof(struct target_epoll_event), 1);
if (!target_ep) {