From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KzQu3-0004FL-GS for qemu-devel@nongnu.org; Mon, 10 Nov 2008 02:09:39 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KzQu2-0004El-Dn for qemu-devel@nongnu.org; Mon, 10 Nov 2008 02:09:38 -0500 Received: from [199.232.76.173] (port=41621 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzQu2-0004Ee-6H for qemu-devel@nongnu.org; Mon, 10 Nov 2008 02:09:38 -0500 Received: from nf-out-0910.google.com ([64.233.182.185]:54409) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KzQu1-0003nM-Oj for qemu-devel@nongnu.org; Mon, 10 Nov 2008 02:09:37 -0500 Received: by nf-out-0910.google.com with SMTP id b2so1547705nfb.12 for ; Sun, 09 Nov 2008 23:09:37 -0800 (PST) From: "Kirill A. Shutemov" Date: Mon, 10 Nov 2008 09:11:28 +0200 Message-Id: <1226301088-4178-1-git-send-email-kirill@shutemov.name> In-Reply-To: <1225129691-11566-1-git-send-email-kirill@shutemov.name> References: <1225129691-11566-1-git-send-email-kirill@shutemov.name> Subject: [Qemu-devel] [PATCH, v3] mmap: add check if requested memory area fits target address space Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Kirill A. Shutemov" Signed-off-by: Kirill A. Shutemov --- linux-user/mmap.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index acb005d..01fd7e9 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -389,6 +389,16 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, 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) { -- 1.6.0.2.GIT