aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>2015-06-26 03:28:24 +0200
committerBen Hutchings <ben@decadent.org.uk>2015-10-13 03:46:01 +0100
commita97233643dcf324d983d92118099213fd08b7fba (patch)
tree8ec7a4e164135cfcb2daeaece59d1b883053ae7e
parentf96051e525023fcb88fe5df5858cbee0371c0b4a (diff)
downloadkernel_samsung_smdk4412-a97233643dcf324d983d92118099213fd08b7fba.zip
kernel_samsung_smdk4412-a97233643dcf324d983d92118099213fd08b7fba.tar.gz
kernel_samsung_smdk4412-a97233643dcf324d983d92118099213fd08b7fba.tar.bz2
xen/gntdevt: Fix race condition in gntdev_release()
commit 30b03d05e07467b8c6ec683ea96b5bffcbcd3931 upstream. 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> Signed-off-by: David Vrabel <david.vrabel@citrix.com> [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-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 c819ba1..5027662 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -493,11 +493,13 @@ 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(map);
}
+ mutex_unlock(&priv->lock);
if (use_ptemod)
mmu_notifier_unregister(&priv->mn, priv->mm);