diff options
author | Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> | 2015-06-26 03:28:24 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-08-16 20:52:19 -0700 |
commit | f90781aa88aaf93f78d8ef7ad002f6ae526ac132 (patch) | |
tree | c1a6aefaef15e51580e47d55332f4dd7d26783be /drivers/xen | |
parent | d24944adc3fb3e128ddb9c695f339b395e798cfb (diff) | |
download | lwn-f90781aa88aaf93f78d8ef7ad002f6ae526ac132.tar.gz lwn-f90781aa88aaf93f78d8ef7ad002f6ae526ac132.zip |
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/gntdev.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index 89274850741b..4bd23bba816f 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -568,12 +568,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); |