From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: "Jan-Simon =?utf-8?q?M=C3=B6ller?=" Date: Wed, 26 Aug 2009 00:02:02 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200908260002.03066.dl9pf@gmx.de> Subject: [Qemu-devel] [Patch] linux-user/syscall.c - don't add GUEST_BASE to NULL pointer List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL po= inter on arg5 . failing call:=20 mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) =3D -1 EFAULT= (Bad address) correct call: mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) =3D 0 Signed-off-by: Jan-Simon M=C3=B6ller =2D-- 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 =2D-- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4445,12 +4445,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_lon= g arg1, p3 =3D lock_user_string(arg3); if (!p || !p2 || !p3) ret =3D -TARGET_EFAULT; =2D else + else { /* FIXME - arg5 should be locked, but it isn't= clear how to * do that since it's not guaranteed to be a N= ULL-terminated * string. */ =2D ret =3D get_errno(mount(p, p2, p3, (unsigned= long)arg4, g2h(arg5))); + if ( ! arg5 ) + ret =3D get_errno(mount(p, p2, p3, (unsign= ed long)arg4, NULL)); + else + ret =3D get_errno(mount(p, p2, p3, (unsign= ed long)arg4, g2h(arg5))); + } unlock_user(p, arg1, 0); unlock_user(p2, arg2, 0); unlock_user(p3, arg3, 0);