[5958] linux-user: mmap: add check if requested memory area fits target address space
Revision: 5958
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5958 Author: aurel32 Date: 2008-12-08 18:12:33 +0000 (Mon, 08 Dec 2008)
Log Message:
-----------
linux-user: mmap: add check if requested memory area fits target address space
Signed-off-by Kirill A. Shutemov <[email protected]>
Signed-off-by Aurelien Jarno <[email protected]>
Modified Paths:
--------------
trunk/linux-user/mmap.c
Modified: trunk/linux-user/mmap.c
===================================================================
linux-user/mmap.c +10 -0
@@ -382,6 +382,16 @@ end = start + len; real_end =HOST_PAGE_ALIGN (end); +/* +* Test if requested memory area fits target address space +* It can fail only on 64-bit host with 32-bit target. +* On any other target/host host mmap() handles this error correctly. +*/ +if ((unsigned long )start + len -1 > (abi_ulong) -1 ) { + errno =EINVAL ; + goto fail; + } +for (addr = real_start; addr < real_end; addr +=TARGET_PAGE_SIZE ) { flg =page_get_flags (addr);if (flg &PAGE_RESERVED ) {