From patchwork Tue Apr 26 12:14:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sassan Panahinejad X-Patchwork-Id: 92913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C8088B6F16 for ; Tue, 26 Apr 2011 22:15:06 +1000 (EST) Received: from localhost ([::1]:56640 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEhAT-00012S-QR for incoming@patchwork.ozlabs.org; Tue, 26 Apr 2011 08:15:01 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52750) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEhAJ-00012F-1d for qemu-devel@nongnu.org; Tue, 26 Apr 2011 08:14:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QEhAI-0001LQ-3U for qemu-devel@nongnu.org; Tue, 26 Apr 2011 08:14:51 -0400 Received: from mail-ww0-f67.google.com ([74.125.82.67]:33767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QEhAH-0001LJ-Tx for qemu-devel@nongnu.org; Tue, 26 Apr 2011 08:14:50 -0400 Received: by wwa36 with SMTP id 36so85414wwa.10 for ; Tue, 26 Apr 2011 05:14:48 -0700 (PDT) Received: by 10.216.48.197 with SMTP id v47mr4432952web.82.1303820088545; Tue, 26 Apr 2011 05:14:48 -0700 (PDT) Received: from localhost.localdomain (cpc2-aztw23-2-0-cust797.aztw.cable.virginmedia.com [94.171.235.30]) by mx.google.com with ESMTPS id d6sm2982326wer.26.2011.04.26.05.14.46 (version=SSLv3 cipher=OTHER); Tue, 26 Apr 2011 05:14:47 -0700 (PDT) From: Sassan Panahinejad To: qemu-devel@nongnu.org Date: Tue, 26 Apr 2011 13:14:25 +0100 Message-Id: <1303820065-25262-1-git-send-email-sassan@sassan.me.uk> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.67 Cc: Sassan Panahinejad Subject: [Qemu-devel] [PATCH] Fix bug with virtio-9p fsync X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Sassan Panahinejad --- hw/virtio-9p.c | 6 +++++- 1 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) 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); }