With some programs the 2.6 kernel can end up allocating memory at address zero, for a non-MAP_FIXED mmap call! This causes problems with some programs and is generally rude to do. This simple patch fixes the problem in my tests.
Make sure that we don't allocate memory all the way down to zero, so the NULL pointer never gets covered up with anonymous memory and we don't end up violating the C standard.
Signed-off-by: Rik van Riel <[EMAIL PROTECTED]>
--- linux-2.6.9/mm/mmap.c.nullmmap 2005-01-25 18:00:26.000000000 -0500 +++ linux-2.6.9/mm/mmap.c 2005-01-26 08:48:03.438701673 -0500 @@ -1114,6 +1114,8 @@ void arch_unmap_area(struct vm_area_stru area->vm_mm->free_area_cache = area->vm_start; }
+#define SHLIB_BASE 0x00111000 + /* * This mmap-allocator allocates new areas top-down from below the * stack's low limit (the base): @@ -1162,6 +1164,13 @@ try_again: return addr;
/* + * Make sure we don't allocate all the way down to + * zero, which would break NULL pointer detection. + */ + if (addr < SHLIB_BASE) + goto fail; + + /* * new region fits between prev_vma->vm_end and * vma->vm_start, use it: */ @@ -1258,8 +1267,6 @@ get_unmapped_area_prot(struct file *file EXPORT_SYMBOL(get_unmapped_area_prot);
-#define SHLIB_BASE 0x00111000
-
unsigned long arch_get_unmapped_exec_area(struct file *filp, unsigned long addr0,
unsigned long len0, unsigned long pgoff, unsigned long flags)
{
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/