From patchwork Tue Mar 30 18:49:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 49413 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 36651B7CFA for ; Tue, 6 Apr 2010 04:00:06 +1000 (EST) Received: from localhost ([127.0.0.1]:34062 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nyqag-0003F1-Mn for incoming@patchwork.ozlabs.org; Mon, 05 Apr 2010 14:00:02 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NyqEp-0003Ep-2H for qemu-devel@nongnu.org; Mon, 05 Apr 2010 13:37:27 -0400 Received: from [140.186.70.92] (port=47476 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NyqEl-0003DQ-Ug for qemu-devel@nongnu.org; Mon, 05 Apr 2010 13:37:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NyqEk-0001Bo-Nd for qemu-devel@nongnu.org; Mon, 05 Apr 2010 13:37:23 -0400 Received: from are.twiddle.net ([75.149.56.221]:60860) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NyqEk-0001BY-FH for qemu-devel@nongnu.org; Mon, 05 Apr 2010 13:37:22 -0400 Received: by are.twiddle.net (Postfix, from userid 5000) id 74529CB4; Mon, 5 Apr 2010 10:37:21 -0700 (PDT) Message-Id: In-Reply-To: References: From: Richard Henderson Date: Tue, 30 Mar 2010 11:49:18 -0700 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 3/7] linux-user: Use guest_start_len_valid in msync. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Make sure to properly handle len = 0 first. Signed-off-by: Richard Henderson --- linux-user/mmap.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 46923c7..f4d44a8 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -706,15 +706,18 @@ int target_msync(abi_ulong start, abi_ulong len, int flags) { abi_ulong end; - if (start & ~TARGET_PAGE_MASK) + if (start & ~TARGET_PAGE_MASK) { return -EINVAL; + } + if (len == 0) { + return 0; + } len = TARGET_PAGE_ALIGN(len); - end = start + len; - if (end < start) + if (!guest_start_len_valid(start, len)) { return -EINVAL; - if (end == start) - return 0; + } + end = start + len; start &= qemu_host_page_mask; return msync(g2h(start), end - start, flags); }