All of lore.kernel.org
 help / color / mirror / Atom feed
* [TRIVIAL PATCH 2.4.20] madvise_willneed makes bad limit comparison
@ 2002-12-09  4:04 Kingsley Cheung
  2002-12-09  4:53 ` [TRIVIAL PATCH 2.5.50] " Kingsley Cheung
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kingsley Cheung @ 2002-12-09  4:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: trivial

Hi,

'madvise_willneed' makes an incorrect rss limit comparison.  It
directly compares rlim[RLIMIT_RSS].rlim_cur to rss. The former is in
bytes, whereas the latter is in pages.  The fix for this is trivial.

[As an aside, one question is whether this limit check is needed at
all.  Most rss limit enforcement implementations that I've seen are
'soft', whereas this would give the limit 'hard' semantics.  Do we
really want 'hard' limit semantics?]


diff -urN linux-2.4.20/mm/filemap.c linux-2.4.20patched/mm/filemap.c
--- linux-2.4.20/mm/filemap.c   Mon Dec  9 14:19:13 2002
+++ linux-2.4.20patched/mm/filemap.c    Mon Dec  9 14:36:08 2002
@@ -2471,10 +2471,12 @@
 
        /* Make sure this doesn't exceed the process's max rss. */
        error = -EIO;
-       rlim_rss = current->rlim ?  current->rlim[RLIMIT_RSS].rlim_cur :
-                               LONG_MAX; /* default: see resource.h */
-       if ((vma->vm_mm->rss + (end - start)) > rlim_rss)
-               return error;
+       rlim_rss = current->rlim[RLIMIT_RSS].rlim_cur;
+       if (rlim_rss != RLIM_INFINITY) {
+               rlim_rss >>= PAGE_SHIFT;
+               if ((vma->vm_mm->rss + (end - start)) > rlim_rss)
+                       return error;
+       }
 
        /* round to cluster boundaries if this isn't a "random" area. */
        if (!VM_RandomReadHint(vma)) {


--
		Kingsley

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-12-10  7:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-09  4:04 [TRIVIAL PATCH 2.4.20] madvise_willneed makes bad limit comparison Kingsley Cheung
2002-12-09  4:53 ` [TRIVIAL PATCH 2.5.50] " Kingsley Cheung
2002-12-09  6:29 ` [TRIVIAL PATCH 2.4.20] " Andrew Morton
2002-12-10  6:08   ` Kingsley Cheung
2002-12-10  7:55     ` Andrew Morton
2002-12-09 19:27 ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.