WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-ia64-devel] [PATCH 2/4] linux/blktap: fix racy memory refernce with

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH 2/4] linux/blktap: fix racy memory refernce with ring_ok
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Tue, 28 Apr 2009 12:01:18 +0900
Cc: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>, jbeulich@xxxxxxxxxx, xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Mon, 27 Apr 2009 20:03:16 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.18 (2008-05-17)
blktap: fix race memory refernce with ring_ok.

fix race memory refernce with ring_ok.
ring_ok is shared by mmapping process and blktap kernel thread.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>

diff --git a/drivers/xen/blktap/blktap.c b/drivers/xen/blktap/blktap.c
--- a/drivers/xen/blktap/blktap.c
+++ b/drivers/xen/blktap/blktap.c
@@ -617,6 +617,9 @@ static int blktap_release(struct inode *
        if (!info)
                return 0;
 
+       info->ring_ok = 0;
+       smp_wmb();
+
        info->dev_inuse = 0;
        DPRINTK("Freeing device [/dev/xen/blktap%d]\n",info->minor);
 
@@ -717,6 +720,7 @@ static int blktap_mmap(struct file *filp
 #endif
 
        info->vma = vma;
+       smp_wmb();
        info->ring_ok = 1;
        return 0;
  fail:
@@ -1390,6 +1394,7 @@ static void dispatch_rw_block_io(blkif_t
                WPRINTK("blktap: ring not ready for requests!\n");
                goto fail_response;
        }
+       smp_rmb();
 
        if (RING_FULL(&info->ufe_ring)) {
                WPRINTK("blktap: fe_ring is full, can't add "

Attachment: 1-fix-race-in-blktap.patch
Description: Text Data

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH 2/4] linux/blktap: fix racy memory refernce with ring_ok, Isaku Yamahata <=