summaryrefslogtreecommitdiff
blob: ecf4ccddb98acc4ca85f2c6fa946af2c85e176ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff -Naru a/fs/eventpoll.c b/fs/eventpoll.c
--- a/fs/eventpoll.c	2005-04-29 17:08:35 -07:00
+++ b/fs/eventpoll.c	2005-04-29 17:08:35 -07:00
@@ -619,6 +619,7 @@
 	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,7 +636,7 @@
 		     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 */
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2005/03/08 08:18:50-08:00 torvalds@ppc970.osdl.org 
#   epoll: return proper error on overflow condition
#   
#   Noted by Georgi Guninski.
# 
# fs/eventpoll.c
#   2005/03/08 08:18:40-08:00 torvalds@ppc970.osdl.org +2 -1
#   epoll: return proper error on overflow condition
#   
#   Noted by Georgi Guninski.
#