|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [PATCH 08/12] xen/gntdev: Fix circular locking dependency
From: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
apply_to_page_range will acquire PTE lock while priv->lock is held,
and mn_invl_range_start tries to acquire priv->lock with PTE already
held. Fix by not holding priv->lock during the entire map operation.
This is safe because map->vma is set nonzero while the lock is held,
which will cause subsequent maps to fail and will cause the unmap
ioctl (and other users of gntdev_del_map) to return -EBUSY until the
area is unmapped. It is similarly impossible for gntdev_vma_close to
be called while the vma is still being created.
Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
---
drivers/xen/gntdev.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index a2ea533..aba76d4 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -575,21 +575,26 @@ static int gntdev_mmap(struct file *flip, struct
vm_area_struct *vma)
if (!(vma->vm_flags & VM_WRITE))
map->flags |= GNTMAP_readonly;
+ spin_unlock(&priv->lock);
+
err = apply_to_page_range(vma->vm_mm, vma->vm_start,
vma->vm_end - vma->vm_start,
find_grant_ptes, map);
if (err) {
printk(KERN_WARNING "find_grant_ptes() failure.\n");
- goto unlock_out;
+ return err;
}
err = map_grant_pages(map);
if (err) {
printk(KERN_WARNING "map_grant_pages() failure.\n");
- goto unlock_out;
+ return err;
}
+
map->is_mapped = 1;
+ return 0;
+
unlock_out:
spin_unlock(&priv->lock);
return err;
--
1.5.6.5
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [PATCH v2 00/12] xen: allow usermode to map granted pages, Stefano Stabellini
- [Xen-devel] [PATCH 01/12] xen: define gnttab_set_map_op/unmap_op, stefano . stabellini
- [Xen-devel] [PATCH 03/12] xen/gntdev: add VM_PFNMAP to vma, stefano . stabellini
- [Xen-devel] [PATCH 02/12] xen/gntdev: allow usermode to map granted pages, stefano . stabellini
- [Xen-devel] [PATCH 04/12] xen: move p2m handling to separate file, stefano . stabellini
- [Xen-devel] [PATCH 05/12] xen: add m2p override mechanism, stefano . stabellini
- [Xen-devel] [PATCH 06/12] xen: gntdev: move use of GNTMAP_contains_pte next to the map_op, stefano . stabellini
- [Xen-devel] [PATCH 07/12] xen/gntdev: stop using "token" argument, stefano . stabellini
- [Xen-devel] [PATCH 08/12] xen/gntdev: Fix circular locking dependency,
stefano . stabellini <=
- [Xen-devel] [PATCH 09/12] xen p2m: transparently change the p2m mappings in the m2p override, stefano . stabellini
- [Xen-devel] [PATCH 10/12] xen: introduce gnttab_map_refs and gnttab_unmap_refs, stefano . stabellini
- [Xen-devel] [PATCH 11/12] xen gntdev: use gnttab_map_refs and gnttab_unmap_refs, stefano . stabellini
- [Xen-devel] [PATCH 12/12] xen p2m: clear the old pte when adding a page to m2p_override, stefano . stabellini
|
|
|
|
|