Skip to contentSkip to conversation

linux-user: guard mmap_next_start from specific maps

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: guard mmap_next_start from specific maps

If the guest process tells us to map at a specific address, we shouldn't increase the "last automatic mapping ended here" variable.

This patch brings the reserved_va code in line with the default case.

---
 linux-user/mmap.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
linux-user/mmap.c +5 -1
index 2245f40..a0c1347 100644
@@ -253,7 +253,11 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size)
             }
         }
     }
-    mmap_next_start = addr;
+
+    if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) {
+        mmap_next_start = addr;
+    }
+
     return last_addr;
 }
 #endif
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 2 lines

If the guest process tells us to map at a specific address, we shouldn't increase the "last automatic mapping ended here" variable.

That sounds reasonable, in fact I'd go further. Tests on an x86-linux machine (both 32-bit and 64-bit userspace) show that if the requested address is not available then it is completely ignored.

linux-user/mmap.c static abi_ulong mmap_find_vma_reserved(abi_ulong start, abi_ulong size) · line 258

Quoted 2 lines
linux-user/mmap.c +2 -0
+    if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) {
+        mmap_next_start = addr;

Code does not match description.

Paul