Commit 30b4c1c8 authored by Linus Torvalds's avatar Linus Torvalds

epoll: return proper error on overflow condition

Noted by Georgi Guninski.
parent 726a1180
......@@ -619,6 +619,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
return error;
}
#define MAX_EVENTS (INT_MAX / sizeof(struct epoll_event))
/*
* Implement the event wait interface for the eventpoll file. It is the kernel
......@@ -635,7 +636,7 @@ asmlinkage long sys_epoll_wait(int epfd, struct epoll_event __user *events,
current, epfd, events, maxevents, timeout));
/* The maximum number of event must be greater than zero */
if (maxevents <= 0)
if (maxevents <= 0 || maxevents > MAX_EVENTS)
return -EINVAL;
/* Verify that the area passed by the user is writeable */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment