linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] prevent NULL mmap in topdown model
@ 2005-05-18 19:57 Rik van Riel
  2005-05-18 20:38 ` Arjan van de Ven
  2005-05-18 22:39 ` Linus Torvalds
  0 siblings, 2 replies; 12+ messages in thread
From: Rik van Riel @ 2005-05-18 19:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm

This (trivial) patch prevents the topdown allocator from allocating
mmap areas all the way down to address zero.  It's not the prettiest
patch, so suggestions for improvement are welcome ;)

Signed-off-by: Rik van Riel <riel@redhat.com>

--- linux-2.6.11/mm/mmap.c.nullptr	2005-05-17 23:07:26.000000000 -0400
+++ linux-2.6.11/mm/mmap.c	2005-05-17 23:18:53.000000000 -0400
@@ -1251,7 +1251,7 @@
 	addr = mm->free_area_cache;
 
 	/* make sure it can fit in the remaining address space */
-	if (addr >= len) {
+	if (addr >= (len + mm->brk)) {
 		vma = find_vma(mm, addr-len);
 		if (!vma || addr <= vma->vm_start)
 			/* remember the address as a hint for next time */
@@ -1267,13 +1267,13 @@
 		 * return with success:
 		 */
 		vma = find_vma(mm, addr);
-		if (!vma || addr+len <= vma->vm_start)
+		if ((!vma || addr+len <= vma->vm_start) && addr > mm->brk)
 			/* remember the address as a hint for next time */
 			return (mm->free_area_cache = addr);
 
 		/* try just below the current vma->vm_start */
 		addr = vma->vm_start-len;
-	} while (len <= vma->vm_start);
+	} while (len <= vma->vm_start && addr > mm->brk);
 
 	/*
 	 * A failed mmap() very likely causes application failure,
--
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>

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

end of thread, other threads:[~2005-05-31 16:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-18 19:57 [PATCH] prevent NULL mmap in topdown model Rik van Riel
2005-05-18 20:38 ` Arjan van de Ven
2005-05-18 21:16   ` Rik van Riel
2005-05-18 22:41     ` Linus Torvalds
2005-05-18 22:39 ` Linus Torvalds
2005-05-19  2:25   ` Rik van Riel
2005-05-19  2:47     ` Linus Torvalds
2005-05-19  6:46       ` Chris Wright
2005-05-19  8:15         ` Arjan van de Ven
2005-05-19  8:23           ` Chris Wright
2005-05-29 21:16           ` Greg Stark
2005-05-31 16:56             ` Chris Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox