diff options
author | Davide Libenzi <davidel@xmailserver.org> | 2005-09-28 04:45:33 (GMT) |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-28 14:46:41 (GMT) |
commit | e3306dd5f7eb2e699f36a4a313fca4b48b18d5e1 (patch) | |
tree | 2b9a02d3b5b4fdd421267ff7c925222a5caddb79 /fs/eventpoll.c | |
parent | f2d613799af915da1fd78463ba8ec5086a0d6f92 (diff) | |
download | linux-e3306dd5f7eb2e699f36a4a313fca4b48b18d5e1.tar.xz |
[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.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 403b90a..4284cd3 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -101,6 +101,10 @@ /* Maximum number of poll wake up nests we are allowing */ #define EP_MAX_POLLWAKE_NESTS 4 +/* Maximum msec timeout value storeable in a long int */ +#define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ) + + struct epoll_filefd { struct file *file; int fd; @@ -1506,8 +1510,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, * and the overflow condition. The passed timeout is in milliseconds, * that why (t * HZ) / 1000. */ - jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? - MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; + jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ? + MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000; retry: write_lock_irqsave(&ep->lock, flags); |