Commit 45bc1f5264a6835239e1c183b78d40bb45310f6c
1 parent
fb1c2cd7
linux-user: mmap: add check if requested memory area fits target address space
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5958 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
10 additions
and
0 deletions
linux-user/mmap.c
... | ... | @@ -382,6 +382,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, |
382 | 382 | end = start + len; |
383 | 383 | real_end = HOST_PAGE_ALIGN(end); |
384 | 384 | |
385 | + /* | |
386 | + * Test if requested memory area fits target address space | |
387 | + * It can fail only on 64-bit host with 32-bit target. | |
388 | + * On any other target/host host mmap() handles this error correctly. | |
389 | + */ | |
390 | + if ((unsigned long)start + len - 1 > (abi_ulong) -1) { | |
391 | + errno = EINVAL; | |
392 | + goto fail; | |
393 | + } | |
394 | + | |
385 | 395 | for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) { |
386 | 396 | flg = page_get_flags(addr); |
387 | 397 | if (flg & PAGE_RESERVED) { | ... | ... |