Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mz4mX-0004FA-IX for qemu-devel@nongnu.org; Sat, 17 Oct 2009 04:36:57 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mz4mV-0004Du-Lz for qemu-devel@nongnu.org; Sat, 17 Oct 2009 04:36:56 -0400 Received: from [199.232.76.173] (port=57424 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mz4mV-0004Do-JK for qemu-devel@nongnu.org; Sat, 17 Oct 2009 04:36:55 -0400 Received: from narury.org ([84.20.150.76]:40197) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Mz4mV-0007Li-2E for qemu-devel@nongnu.org; Sat, 17 Oct 2009 04:36:55 -0400 Date: Sat, 17 Oct 2009 11:36:52 +0300 From: Riku Voipio Subject: Re: [Qemu-devel] [Patch] Resend: linux-user/syscall.c - don't add GUEST_BASE to NULL pointer Message-ID: <20091017083652.GA19198@kos.to> References: <200910162355.45511.dl9pf@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <200910162355.45511.dl9pf@gmx.de> Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan-Simon =?utf-8?Q?M=C3=B6ller?= Cc: qemu-devel@nongnu.org On Fri, Oct 16, 2009 at 11:55:45PM +0200, Jan-Simon M=C3=B6ller wrote: > This patch fixes the mount call. GUEST_BASE shouldn't be added to a NUL= L=20 > pointer on arg5 . > failing call:=20 > mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) =3D -1 EF= AULT (Bad=20 > address) > correct call: > mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) =3D 0 The patch looks functionally correct, but your mailer has mangled it. > Signed-off-by: =C2=A0Jan-Simon M=C3=B6ller =C2=A0 > --- > =C2=A0linux-user/syscall.c | =C2=A0 =C2=A08 ++++++-- > =C2=A01 files changed, 6 insertions(+), 2 deletions(-) >=20 > 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=20 > arg1, > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 p3 =3D lock_user_string(arg3); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0if (!p || !p2 || !p3) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D -TARGET_EFAULT; > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0else > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0else { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* FIXME - arg5 should be locked, but it i= sn't=20 > clear how to > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * do that since it's not guaranteed to be= a=20 > NULL-terminated > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 * string. > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 */ > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D get_errno(mount(p, p2, p3, (unsigned=20 > long)arg4, g2h(arg5))); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0if ( ! arg5 ) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D get_errno(mount(p, p2, = p3, (unsigned=20 > long)arg4, NULL)); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0else > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ret =3D get_errno(mount(p, p2, = p3, (unsigned=20 > long)arg4, g2h(arg5))); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0} > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0unlock_user(p, arg1, 0); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0unlock_user(p2, arg2, 0); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0unlock_user(p3, arg3, 0); >=20