From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9kex-0003Av-1X for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:16:43 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9kew-0003AO-DT for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:16:42 -0500 Received: from [199.232.76.173] (port=38112 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9kew-0003AK-3Z for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:16:42 -0500 Received: from hall.aurel32.net ([88.191.82.174]:42657) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L9kev-0004CR-HL for qemu-devel@nongnu.org; Mon, 08 Dec 2008 13:16:41 -0500 Date: Mon, 8 Dec 2008 19:16:39 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] [PATCH] mmap: add check if requested memory area fits target address space Message-ID: <20081208181639.GF14780@volta.aurel32.net> References: <1228303789-25653-1-git-send-email-kirill@shutemov.name> <1228303789-25653-2-git-send-email-kirill@shutemov.name> <1228303789-25653-3-git-send-email-kirill@shutemov.name> <1228303789-25653-4-git-send-email-kirill@shutemov.name> <1228303789-25653-5-git-send-email-kirill@shutemov.name> <1228303789-25653-6-git-send-email-kirill@shutemov.name> <1228303789-25653-7-git-send-email-kirill@shutemov.name> <1228303789-25653-8-git-send-email-kirill@shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1228303789-25653-8-git-send-email-kirill@shutemov.name> 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" On Wed, Dec 03, 2008 at 01:29:43PM +0200, Kirill A. Shutemov wrote: > Signed-off-by: Kirill A. Shutemov Applied, thanks. > --- > 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 d96917d..52e2dc8 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 > > > > -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net