From patchwork Tue Aug 25 22:02:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jan-Simon_M=C3=B6ller?= X-Patchwork-Id: 32096 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 713AFB7B65 for ; Wed, 26 Aug 2009 08:03:36 +1000 (EST) Received: from localhost ([127.0.0.1]:46098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mg472-0003Rm-IE for incoming@patchwork.ozlabs.org; Tue, 25 Aug 2009 18:03:32 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mg45p-0002yq-R9 for qemu-devel@nongnu.org; Tue, 25 Aug 2009 18:02:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mg45i-0002vT-5u for qemu-devel@nongnu.org; Tue, 25 Aug 2009 18:02:15 -0400 Received: from [199.232.76.173] (port=39395 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mg45h-0002vF-Iu for qemu-devel@nongnu.org; Tue, 25 Aug 2009 18:02:09 -0400 Received: from mail.gmx.net ([213.165.64.20]:55745) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1Mg45f-0000xd-SU for qemu-devel@nongnu.org; Tue, 25 Aug 2009 18:02:08 -0400 Received: (qmail invoked by alias); 25 Aug 2009 22:02:04 -0000 Received: from ip180156.wh.uni-hannover.de (EHLO ip180156.wh.uni-hannover.de) [130.75.180.156] by mail.gmx.net (mp012) with SMTP; 26 Aug 2009 00:02:04 +0200 X-Authenticated: #7313500 X-Provags-ID: V01U2FsdGVkX1/fMyE26yPf55YWoKTtO4O5LAms67mC3+rMetXkxC 7nm+MKJMQrdsVJ From: "Jan-Simon =?utf-8?q?M=C3=B6ller?=" To: qemu-devel@nongnu.org Date: Wed, 26 Aug 2009 00:02:02 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200908260002.03066.dl9pf@gmx.de> X-Y-GMX-Trusted: 0 X-FuHaFi: 0.5 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to NULL pointer 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 This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 . failing call: mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address) correct call: mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) = 0 Signed-off-by: Jan-Simon Möller --- linux-user/syscall.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 673eed4..5b2ec4f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4445,12 +4445,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, p3 = lock_user_string(arg3); if (!p || !p2 || !p3) ret = -TARGET_EFAULT; - else + else { /* FIXME - arg5 should be locked, but it isn't clear how to * do that since it's not guaranteed to be a NULL-terminated * string. */ - ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5))); + if ( ! arg5 ) + ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL)); + else + ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5))); + } unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0);