Limit max_user_watches to prevent integer overflow.
A message that is not in the archive (sent off-list or not yet received): [email protected]
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.
Signed-off-by Robin Holt <[email protected]>
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
@@ -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);