qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] Fix bug with virtio-9p fsync


From: Sassan Panahinejad
Subject: [Qemu-devel] [PATCH] Fix bug with virtio-9p fsync
Date: Mon, 25 Apr 2011 18:54:05 +0100

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 
therefore accesses the wrong element of the fs union.
This error can result in guest applications failing (in my case it was dpkg).
This patch fixes the issue, although there may be other, similar bugs in 
virtio-9p.
---
 hw/virtio-9p.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 7e29535..09fb5da 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1875,7 +1875,10 @@ static void v9fs_fsync(V9fsState *s, V9fsPDU *pdu)
         v9fs_post_do_fsync(s, pdu, err);
         return;
     }
-    err = v9fs_do_fsync(s, fidp->fs.fd, datasync);
+    if (fidp->fid_type == P9_FID_DIR)
+        err = v9fs_do_fsync(s, dirfd(fidp->fs.dir), datasync);
+    else
+        err = v9fs_do_fsync(s, fidp->fs.fd, datasync);
     v9fs_post_do_fsync(s, pdu, err);
 }
 
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]