aboutsummaryrefslogtreecommitdiffstats
path: root/fs/eventpoll.c
diff options
context:
space:
mode:
authorDavide Libenzi <davidel@xmailserver.org>2005-09-28 00:45:33 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-28 10:46:41 -0400
commite3306dd5f7eb2e699f36a4a313fca4b48b18d5e1 (patch)
tree2b9a02d3b5b4fdd421267ff7c925222a5caddb79 /fs/eventpoll.c
parentf2d613799af915da1fd78463ba8ec5086a0d6f92 (diff)
[PATCH] epoll: handle timeout overflow
Handle the timeout upper boundary for epoll. Signed-off-by: Davide Libenzi <davidel@xmailserver.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/eventpoll.c')
-rw-r--r--fs/eventpoll.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 403b90a1213d..4284cd31eba6 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -101,6 +101,10 @@
101/* Maximum number of poll wake up nests we are allowing */ 101/* Maximum number of poll wake up nests we are allowing */
102#define EP_MAX_POLLWAKE_NESTS 4 102#define EP_MAX_POLLWAKE_NESTS 4
103 103
104/* Maximum msec timeout value storeable in a long int */
105#define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ)
106
107
104struct epoll_filefd { 108struct epoll_filefd {
105 struct file *file; 109 struct file *file;
106 int fd; 110 int fd;
@@ -1506,8 +1510,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
1506 * and the overflow condition. The passed timeout is in milliseconds, 1510 * and the overflow condition. The passed timeout is in milliseconds,
1507 * that why (t * HZ) / 1000. 1511 * that why (t * HZ) / 1000.
1508 */ 1512 */
1509 jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? 1513 jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ?
1510 MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; 1514 MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000;
1511 1515
1512retry: 1516retry:
1513 write_lock_irqsave(&ep->lock, flags); 1517 write_lock_irqsave(&ep->lock, flags);