mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 12:23:53 -06:00
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>
This commit is contained in:
parent
700fa58e4b
commit
2ba7fae3bd
2 changed files with 8 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue