summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>2015-06-26 04:28:24 +0300
committerSasha Levin <sasha.levin@oracle.com>2015-08-27 20:25:25 +0300
commit728757eda0dcdfac1f8d46548849cbf2597fe5da (patch)
tree8d3fa0e5b1ace57690cecd7252f56b9db322210b /drivers
parent6b4cd0635d2cd27836ab5f534990073e0ee1a2dd (diff)
downloadlinux-728757eda0dcdfac1f8d46548849cbf2597fe5da.tar.xz
xen/gntdevt: Fix race condition in gntdev_release()
[ Upstream commit 30b03d05e07467b8c6ec683ea96b5bffcbcd3931 ] While gntdev_release() is called the MMU notifier is still registered and can traverse priv->maps list even if no pages are mapped (which is the case -- gntdev_release() is called after all). But gntdev_release() will clear that list, so make sure that only one of those things happens at the same time. Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> Cc: <stable@vger.kernel.org> Signed-off-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/xen/gntdev.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index b7f028a8f542..91cc44611062 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -529,12 +529,14 @@ static int gntdev_release(struct inode *inode, struct file *flip)
pr_debug("priv %p\n", priv);
+ mutex_lock(&priv->lock);
while (!list_empty(&priv->maps)) {
map = list_entry(priv->maps.next, struct grant_map, next);
list_del(&map->next);
gntdev_put_map(NULL /* already removed */, map);
}
WARN_ON(!list_empty(&priv->freeable_maps));
+ mutex_unlock(&priv->lock);
if (use_ptemod)
mmu_notifier_unregister(&priv->mn, priv->mm);