提交 e3306dd5 编写于 作者: D Davide Libenzi 提交者: Linus Torvalds

[PATCH] epoll: handle timeout overflow

Handle the timeout upper boundary for epoll.
Signed-off-by: NDavide Libenzi <davidel@xmailserver.org>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 f2d61379
...@@ -101,6 +101,10 @@ ...@@ -101,6 +101,10 @@
/* Maximum number of poll wake up nests we are allowing */ /* Maximum number of poll wake up nests we are allowing */
#define EP_MAX_POLLWAKE_NESTS 4 #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 epoll_filefd {
struct file *file; struct file *file;
int fd; int fd;
...@@ -1506,8 +1510,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, ...@@ -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, * and the overflow condition. The passed timeout is in milliseconds,
* that why (t * HZ) / 1000. * that why (t * HZ) / 1000.
*/ */
jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ?
MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000;
retry: retry:
write_lock_irqsave(&ep->lock, flags); write_lock_irqsave(&ep->lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册