[PATCH] epoll: return proper error on overflow condition

Noted by Georgi Guninski.
This commit is contained in:
torvalds@ppc970.osdl.org 2005-03-09 00:01:53 -08:00 committed by Greg KH
parent d723a9bc72
commit 3f9459a091

View file

@ -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 */