From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:32808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEhqt-000846-2F for qemu-devel@nongnu.org; Tue, 26 Apr 2011 08:58:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QEhqr-0000LC-Pz for qemu-devel@nongnu.org; Tue, 26 Apr 2011 08:58:51 -0400 Received: from mail-gx0-f173.google.com ([209.85.161.173]:58356) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEhqr-0000L5-MX for qemu-devel@nongnu.org; Tue, 26 Apr 2011 08:58:49 -0400 Received: by gxk26 with SMTP id 26so258378gxk.4 for ; Tue, 26 Apr 2011 05:58:49 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1303820065-25262-1-git-send-email-sassan@sassan.me.uk> References: <1303820065-25262-1-git-send-email-sassan@sassan.me.uk> Date: Tue, 26 Apr 2011 13:58:48 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] Fix bug with virtio-9p fsync List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sassan Panahinejad Cc: "Venkateswararao Jujjuri (JV)" , qemu-devel@nongnu.org On Tue, Apr 26, 2011 at 1:14 PM, Sassan Panahinejad w= rote: > v9fs_fsync and possibly others break when asked to operate on a directory= . > It does not check fid_type to see if it is operating on a directory and t= herefore accesses the wrong element of the fs union. > This error can result in guest applications failing (in my case it was dp= kg). > This patch fixes the issue, although there may be other, similar bugs in = virtio-9p. > > Signed-off-by: Sassan Panahinejad > --- > =A0hw/virtio-9p.c | =A0 =A06 +++++- > =A01 files changed, 5 insertions(+), 1 deletions(-) > > diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c > index 7e29535..cc4fdc8 100644 > --- a/hw/virtio-9p.c > +++ b/hw/virtio-9p.c > @@ -1875,7 +1875,11 @@ static void v9fs_fsync(V9fsState *s, V9fsPDU *pdu) > =A0 =A0 =A0 =A0 v9fs_post_do_fsync(s, pdu, err); > =A0 =A0 =A0 =A0 return; > =A0 =A0 } > - =A0 =A0err =3D v9fs_do_fsync(s, fidp->fs.fd, datasync); > + =A0 =A0if (fidp->fid_type =3D=3D P9_FID_DIR) { > + =A0 =A0 =A0 =A0err =3D v9fs_do_fsync(s, dirfd(fidp->fs.dir), datasync); > + =A0 =A0} else { > + =A0 =A0 =A0 =A0err =3D v9fs_do_fsync(s, fidp->fs.fd, datasync); > + =A0 =A0} What about P9_FID_XATTR, seems like we have the same issue there too? wstat, lock, and getlock need closer auditing and perhaps fixing. Stefan