[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/13] linux-user/mmap.c: Avoid choosing NULL as star
From: |
Laurent Vivier |
Subject: |
[Qemu-devel] [PULL 06/13] linux-user/mmap.c: Avoid choosing NULL as start address |
Date: |
Tue, 23 Jan 2018 15:48:00 +0100 |
From: Maximilian Riemensberger <address@hidden>
mmap() is required by the linux kernel ABI and POSIX to return a
non-NULL address when the implementation chooses a start address for the
mapping.
The current implementation of mmap_find_vma_reserved() can return NULL
as start address of a mapping which leads to subsequent crashes inside
the guests glibc, e.g. output of qemu-arm-static --strace executing a
test binary stx_test:
1879
mmap2(NULL,8388608,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS|0x20000,-1,0)
= 0x00000000
1879 write(2,0xf6fd39d0,79) stx_test: allocatestack.c:514: allocate_stack:
Assertion `mem != NULL' failed.
This patch fixes mmap_find_vma_reserved() by skipping NULL as start
address while searching for a suitable mapping start address.
CC: Riku Voipio <address@hidden>
CC: Laurent Vivier <address@hidden>
CC: Peter Maydell <address@hidden>
Signed-off-by: Maximilian Riemensberger <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Laurent Vivier <address@hidden>
---
linux-user/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 4888f53139..0fbfd6dff2 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -234,7 +234,7 @@ static abi_ulong mmap_find_vma_reserved(abi_ulong start,
abi_ulong size)
if (prot) {
end_addr = addr;
}
- if (addr + size == end_addr) {
+ if (addr && addr + size == end_addr) {
break;
}
addr -= qemu_host_page_size;
--
2.14.3
- [Qemu-devel] [PULL 10/13] linux-user: remove nmi.c and fw-path-provider.c, (continued)
- [Qemu-devel] [PULL 02/13] linux-user: wrap fork() in a start/end exclusive section, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 04/13] linux-user: Don't use CMSG_ALIGN(sizeof struct cmsghdr), Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 07/13] linux-user: Fix sched_get/setaffinity conversion, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 11/13] linux-user: Propagate siginfo_t through to handle_cpu_signal(), Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 12/13] page_unprotect(): handle calls to pages that are PAGE_WRITE, Laurent Vivier, 2018/01/23
- [Qemu-devel] [PULL 06/13] linux-user/mmap.c: Avoid choosing NULL as start address,
Laurent Vivier <=
- Re: [Qemu-devel] [PULL 00/13] Linux user for 2.12 patches, Peter Maydell, 2018/01/25