Skip to contentSkip to conversation

linux-user: map at TARGET_UNMAPPED_BASE with reserved_va

PATCH Superseded Alexander Graf 2 participants 2 messages Mar 3, 2012 – Mar 4, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: map at TARGET_UNMAPPED_BASE with reserved_va

When mmap()'ing memory somewhere where it's not allowed, we should not default to the "next free page" which could be right after brk()'ed memory, but rather at TARGET_UNMAPPED_BASE, which ensures that brk() can extend its space later on.

---
 linux-user/mmap.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
linux-user/mmap.c +7 -1
index e4db455..4219b16 100644
@@ -244,7 +244,13 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
         }
         prot = page_get_flags(addr);
         if (prot) {
-            last_addr = addr + qemu_host_page_size;
+            if (addr < mmap_next_start) {
+                /* Someone randomly shot into potential brk space,
+                   better remap higher up when already remapping */
+                last_addr = TASK_UNMAPPED_BASE;
+            } else {
+                last_addr = addr + qemu_host_page_size;
+            }
         }
     }
     mmap_next_start = addr;
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 4 lines

When mmap()'ing memory somewhere where it's not allowed, we should not default to the "next free page" which could be right after brk()'ed memory, but rather at TARGET_UNMAPPED_BASE, which ensures that brk() can extend its space later on.

NACK, As discussed on IRC.

Effectively prevents mmap from allocating below TARGET_UNMAPPED_BASE. This wastes a lot of perfectly good address space. With small -R values it leaves mmap with no usable virtual address space.

Paul