Skip to contentSkip to conversation

Limit max_user_watches to prevent integer overflow.

PATCH New Robin Holt 1 participant 1 message Oct 2, 2010 1 message not in the archive VFS

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Robin Holt

author
#1 lore raw

PATCH 1/1 Limit max_user_watches to prevent integer overflow.

Subject: [Patch] Limit max_user_watches to prevent integer overflow.

On a 16TB machine, max_user_watches has an integer overflow. Limit it to INT_MAX.

To: "Eric W. Biederman" <[email protected]>
To: Davide Libenzi <[email protected]>
To: [email protected]
To: Pekka Enberg <[email protected]>

---

 fs/eventpoll.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/eventpoll.c +3 -2
Index: pv1010933/fs/eventpoll.c
===================================================================
@@ -1415,13 +1415,14 @@ SYSCALL_DEFINE6(epoll_pwait, int, epfd,
 static int __init eventpoll_init(void)
 {
 	struct sysinfo si;
+	long limit;
 
 	si_meminfo(&si);
 	/*
 	 * Allows top 4% of lomem to be allocated for epoll watches (per user).
 	 */
-	max_user_watches = (((si.totalram - si.totalhigh) / 25) << PAGE_SHIFT) /
-		EP_ITEM_COST;
+	limit = (((si.totalram - si.totalhigh) / 25) << PAGE_SHIFT) / EP_ITEM_COST;
+	max_user_watches = min_t(long, limit, INT_MAX);
 
 	/* Initialize the structure used to perform safe poll wait head wake ups */
 	ep_nested_calls_init(&poll_safewake_ncalls);