This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / eventpoll.c
index 7d6a12f..9900e33 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/wait.h>
 #include <linux/eventpoll.h>
 #include <linux/mount.h>
-#include <asm/bitops.h>
+#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <asm/io.h>
@@ -320,7 +320,7 @@ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
 /*
  * This semaphore is used to serialize ep_free() and eventpoll_release_file().
  */
-struct semaphore epsem;
+static struct semaphore epsem;
 
 /* Safe wake up implementation */
 static struct poll_safewake psw;
@@ -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,12 +636,14 @@ 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 */
-       if ((error = verify_area(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))))
+       if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event))) {
+               error = -EFAULT;
                goto eexit_1;
+       }
 
        /* Get the "struct file *" for the eventpoll file */
        error = -EBADF;