]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.10.87/xen-gntdevt-fix-race-condition-in-gntdev_release.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.87 / xen-gntdevt-fix-race-condition-in-gntdev_release.patch
CommitLineData
5f00fb13 1From 30b03d05e07467b8c6ec683ea96b5bffcbcd3931 Mon Sep 17 00:00:00 2001
5dd4eba1 2From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= <marmarek@invisiblethingslab.com>
5f00fb13
GKH
3Date: Fri, 26 Jun 2015 03:28:24 +0200
4Subject: xen/gntdevt: Fix race condition in gntdev_release()
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
5dd4eba1 9From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= <marmarek@invisiblethingslab.com>
5f00fb13
GKH
10
11commit 30b03d05e07467b8c6ec683ea96b5bffcbcd3931 upstream.
12
13While gntdev_release() is called the MMU notifier is still registered
14and can traverse priv->maps list even if no pages are mapped (which is
15the case -- gntdev_release() is called after all). But
16gntdev_release() will clear that list, so make sure that only one of
17those things happens at the same time.
18
19Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
20Signed-off-by: David Vrabel <david.vrabel@citrix.com>
21Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23---
24 drivers/xen/gntdev.c | 2 ++
25 1 file changed, 2 insertions(+)
26
27--- a/drivers/xen/gntdev.c
28+++ b/drivers/xen/gntdev.c
29@@ -534,12 +534,14 @@ static int gntdev_release(struct inode *
30
31 pr_debug("priv %p\n", priv);
32
33+ mutex_lock(&priv->lock);
34 while (!list_empty(&priv->maps)) {
35 map = list_entry(priv->maps.next, struct grant_map, next);
36 list_del(&map->next);
37 gntdev_put_map(NULL /* already removed */, map);
38 }
39 WARN_ON(!list_empty(&priv->freeable_maps));
40+ mutex_unlock(&priv->lock);
41
42 if (use_ptemod)
43 mmu_notifier_unregister(&priv->mn, priv->mm);