mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Holt <holt@sgi.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>,
	Davide Libenzi <davidel@xmailserver.org>,
	linux-kernel@vger.kernel.org,
	Pekka Enberg <penberg@cs.helsinki.fi>
Subject: [Patch] Limit max_user_watches to prevent integer overflow.
Date: Sat, 02 Oct 2010 06:40:52 -0500	[thread overview]
Message-ID: <20101002114057.776282935@gulag1.americas.sgi.com> (raw)
In-Reply-To: <20101002114051.090084116@gulag1.americas.sgi.com>

[-- 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);


           reply	other threads:[~2010-10-02 11:41 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20101002114051.090084116@gulag1.americas.sgi.com>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101002114057.776282935@gulag1.americas.sgi.com \
    --to=holt@sgi.com \
    --cc=davidel@xmailserver.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®