From patchwork Sun Mar 28 00:53:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: takasi-y@ops.dti.ne.jp X-Patchwork-Id: 48766 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 521F5B7CE6 for ; Sun, 28 Mar 2010 11:54:42 +1100 (EST) Received: from localhost ([127.0.0.1]:37860 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nvglz-0001cn-G9 for incoming@patchwork.ozlabs.org; Sat, 27 Mar 2010 20:54:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NvglS-0001ba-HD for qemu-devel@nongnu.org; Sat, 27 Mar 2010 20:54:06 -0400 Received: from [140.186.70.92] (port=41123 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NvglP-0001a8-Mu for qemu-devel@nongnu.org; Sat, 27 Mar 2010 20:54:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NvglN-00038s-HG for qemu-devel@nongnu.org; Sat, 27 Mar 2010 20:54:03 -0400 Received: from smtp12.dti.ne.jp ([202.216.231.187]:52627) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NvglN-00038D-1c for qemu-devel@nongnu.org; Sat, 27 Mar 2010 20:54:01 -0400 Received: from debian.lan (KHP059140016099.ppp-bb.dion.ne.jp [59.140.16.99]) by smtp12.dti.ne.jp (3.11s) with ESMTP AUTH id o2S0rrvk014831; Sun, 28 Mar 2010 09:53:53 +0900 (JST) Date: Sun, 28 Mar 2010 09:53:53 +0900 (JST) Message-Id: <201003280053.o2S0rrvk014831@smtp12.dti.ne.jp> From: takasi-y@ops.dti.ne.jp To: qemu-devel@nongnu.org X-Mailer: Sylpheed 2.5.0 (GTK+ 2.12.12; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Solaris 9 Cc: Richard Henderson Subject: [Qemu-devel] [PATCH] Fix page_check_range() wrap-around check when len=0. 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 Fix page_check_range() wrap-around check when len=0. write(1,"",0) on linux-user emulation should be OK, but fails. This is a regression brought by 376a7909. This patch fixes it at the last of the calling path shown below, do_syscall:write -> access_ok() -> page_check_range(), as linux-kernel does. For example, x86 does it at follows, sys_write() -> access_ok() -> __range_not_ok(). This implies calling page_check_range() with len=0 is valid. Signed-off-by: Takashi YOSHII --- exec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/exec.c b/exec.c index 14767b7..26cd8b9 100644 --- a/exec.c +++ b/exec.c @@ -2410,7 +2410,7 @@ int page_check_range(target_ulong start, target_ulong len, int flags) assert(start < ((abi_ulong)1 << L1_MAP_ADDR_SPACE_BITS)); #endif - if (start + len - 1 < start) { + if (len > 0 && start + len -1 < start) { /* We've wrapped around. */ return -1; }