* [Patch] Limit max_user_watches to prevent integer overflow.
[not found] <20101002114051.090084116@gulag1.americas.sgi.com>
@ 2010-10-02 11:40 ` Robin Holt
0 siblings, 0 replies; only message in thread
From: Robin Holt @ 2010-10-02 11:40 UTC (permalink / raw)
To: Eric W. Biederman, Davide Libenzi, linux-kernel, Pekka Enberg
[-- Attachment #1: max_user_watches_overflow --]
[-- Type: text/plain, Size: 1279 bytes --]
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 <holt@sgi.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
To: Davide Libenzi <davidel@xmailserver.org>
To: linux-kernel@vger.kernel.org
To: Pekka Enberg <penberg@cs.helsinki.fi>
---
fs/eventpoll.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Index: pv1010933/fs/eventpoll.c
===================================================================
--- pv1010933.orig/fs/eventpoll.c 2010-10-02 06:35:37.000000000 -0500
+++ pv1010933/fs/eventpoll.c 2010-10-02 06:38:06.479823590 -0500
@@ -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);
^ permalink raw reply [flat|nested] only message in thread