Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e3306dd5 authored by Davide Libenzi's avatar Davide Libenzi Committed by Linus Torvalds
Browse files

[PATCH] epoll: handle timeout overflow



Handle the timeout upper boundary for epoll.

Signed-off-by: default avatarDavide Libenzi <davidel@xmailserver.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f2d61379
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -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,7 +1510,7 @@ 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 ?
	jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ?
		MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000;

retry: