the flexible-mmap-2.6.7-D5 patch (attached) splits the flexible-mmap layout stuff out of exec-shield. The patch is against 2.6.7 + my latest NX patch. (i've attached the NX patch too, for convenience.) the goal of the patch is to change the way virtual memory is allocated, from: 0x08000000 ... binary image 0x08xxxxxx ... brk area, grows upwards 0x40000000 ... start of mmap, new mmaps go after old ones 0xbfxxxxxx ... stack to a more flexible top-down mmap() method: 0x08000000 ... binary image 0x08xxxxxx ... brk area, grows upwards 0xbfxxxxxx ... _end_ of all mmaps, new mmaps go below old ones 0xbfyyyyyy ... stack the new layout has a couple of advantages: - primarily this layout enables both malloc(), mmap()/shmat() users to utilize the full address space: 3GB on stock x86, 4GB on x86 4:4 or x86-64 running x86 apps. - the new layout is also in essence 'self-tuning' the mmap() and malloc() limits: no hacks like /proc/PID/mmap_base are needed - both malloc() and mmap() can grow until all the address space is full. With the old layout, malloc() space was limited to 900MB, mmap() space to ~2GB. - The new layout also allows very large continuous mmap()s because the 'free space' is always a continuous hole (statistically). - there's also a ~4K pagetable saved per typical process, because we dont allocate at 1GB anymore and dont fragment the VM that much - there are only 2 main chunks, the binary image + brk(), and the mmap() area + stack. here are the kernel code changes the patch introduces: - the patch is compatible with existing architectures that either make use of HAVE_ARCH_UNMAPPED_AREA or use the default mmap() allocator - there is no change in behavior. - the patch gives a new mechanism to define alternate per-mm mmap() layouts via mm->get_unmapped_area(). On x86 i used this mechanism to implement a top-down allocator for PT_GNU_STACK applications. - 64-bit architectures can use the same mechanism to clean up 32-bit compatibility layouts: by defining HAVE_ARCH_PICK_MMAP_LAYOUT and providing a arch_pick_mmap_layout() function - which can then decide between various mmap() layout functions. - i also introduced a new personality bit (ADDR_COMPAT_LAYOUT) to signal older binaries that dont have PT_GNU_STACK. x86 uses this to revert back to the stock layout. I also changed x86 to not clear the personality bits upon exec(), like x86-64 already does. - once every architecture that uses HAVE_ARCH_UNMAPPED_AREA has defined its arch_pick_mmap_layout() function, we can get rid of HAVE_ARCH_UNMAPPED_AREA altogether, as a final cleanup. i tested the patch on two distributions: one was an older one without PT_GNU_STACK, the other had applications was with PT_GNU_STACK. On the old one we properly generate the compatible VM layout - the PT_GNU_STACK one got the new layout. the new layout generation function (__get_unmapped_area()) got significant testing in Fedora Core 1/2 and RHEL3, so it's pretty robust. Compatibility: there's one known public application that broke in Fedora, a serial terminal program. The application bug has been fixed. Comments, suggestions are welcome, Ingo