linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: Andrew Morton <akpm@osdl.org>
Cc: hugh@veritas.com, chrisw@osdl.org, linux-mm@kvack.org
Subject: Re: rlimit_as-checking-fix.patch
Date: Tue, 26 Apr 2005 23:41:39 -0700	[thread overview]
Message-ID: <20050427064139.GO493@shell0.pdx.osdl.net> (raw)
In-Reply-To: <20050426230050.3bcffe8a.akpm@osdl.org>

* Andrew Morton (akpm@osdl.org) wrote:
> Andrew Morton <akpm@osdl.org> wrote:
> >
> > review, please?
> 
> crappy reviewers.  Tested version.

Sorry to be so slow on that one.  Here's an update for the mlock part.
It's only compile tested as of yet.




Always use page counts when doing RLIMIT_MEMLOCK checking to avoid
possible overflow.

Signed-off-by: Chris Wright <chrisw@osdl.org>
---

mm/mmap.c: 6ea204cc751e4d2f0fe4a7d213bab9ae90ad58c4
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -937,9 +937,10 @@ unsigned long do_mmap_pgoff(struct file 
 	/* mlock MCL_FUTURE? */
 	if (vm_flags & VM_LOCKED) {
 		unsigned long locked, lock_limit;
-		locked = mm->locked_vm << PAGE_SHIFT;
+		locked = len >> PAGE_SHIFT;
+		locked += mm->locked_vm;
 		lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
-		locked += len;
+		lock_limit >>= PAGE_SHIFT;
 		if (locked > lock_limit && !capable(CAP_IPC_LOCK))
 			return -EAGAIN;
 	}
@@ -1823,9 +1824,10 @@ unsigned long do_brk(unsigned long addr,
 	 */
 	if (mm->def_flags & VM_LOCKED) {
 		unsigned long locked, lock_limit;
-		locked = mm->locked_vm << PAGE_SHIFT;
+		locked = len >> PAGE_SHIFT;
+		locked += mm->locked_vm;
 		lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
-		locked += len;
+		lock_limit >>= PAGE_SHIFT;
 		if (locked > lock_limit && !capable(CAP_IPC_LOCK))
 			return -EAGAIN;
 	}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  reply	other threads:[~2005-04-27  6:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-26  2:55 rlimit_as-checking-fix.patch Andrew Morton
2005-04-27  6:00 ` rlimit_as-checking-fix.patch Andrew Morton
2005-04-27  6:41   ` Chris Wright [this message]
2005-04-27  6:23 ` rlimit_as-checking-fix.patch Chris Wright
2005-04-27  6:28   ` rlimit_as-checking-fix.patch Andrew Morton

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=20050427064139.GO493@shell0.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=linux-mm@kvack.org \
    /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