]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
[PATCH] epoll: return proper error on overflow condition
authortorvalds@ppc970.osdl.org <torvalds@ppc970.osdl.org>
Wed, 9 Mar 2005 08:01:53 +0000 (00:01 -0800)
committerGreg KH <gregkh@suse.de>
Thu, 12 May 2005 17:00:06 +0000 (10:00 -0700)
Noted by Georgi Guninski.

fs/eventpoll.c

index b11ab1a9ceeed9f5ea9f1ac39d2d1fd475661872..28ecd4ddf522c4a1a50ba4f9a90372315596cf02 100644 (file)
@@ -619,6 +619,7 @@ eexit_1:
        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 */