SHA256
1
0
forked from pool/qemu
qemu/0047-linux-user-map-at-TARGET_UNMAPPED_BASE-with-reserved.patch
Alexander Graf 44bce8debe - update update_git.sh for 1.0.1
- add fixes for reserved_va mmap(NULL) case, fixes git build on arm

OBS-URL: https://build.opensuse.org/package/show/Virtualization/qemu?expand=0&rev=59
2012-03-03 23:28:15 +00:00

42 lines
1.4 KiB
Diff

From 76d6efef547a23ba6e4e1ed0f1f198b36ae9c7ff Mon Sep 17 00:00:00 2001
From: Alexander Graf <agraf@suse.de>
Date: Sat, 3 Mar 2012 23:14:31 +0100
Subject: [PATCH] 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.
Reported-by: Bernhard M. Wiedemann <bwiedemann@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
v1 -> v2:
- use consistent constant naming
---
linux-user/mmap.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index e4db455..2245f40 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -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 < TASK_UNMAPPED_BASE) {
+ /* 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;