summaryrefslogtreecommitdiffstats
path: root/drivers/xen/gntdev.c
diff options
context:
space:
mode:
authorJuergen Gross <jgross@suse.com>2017-10-25 11:08:07 -0400
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2017-10-25 12:48:13 -0400
commit298d275d4d9bea3524ff4bc76678c140611d8a8d (patch)
tree4337329fdc85462328edb08a35f6c373c82ab6f1 /drivers/xen/gntdev.c
parente1043a4bb9fce6cfc7d55c5767e429a18ac8c4eb (diff)
xen/gntdev: avoid out of bounds access in case of partial gntdev_mmap()
In case gntdev_mmap() succeeds only partially in mapping grant pages it will leave some vital information uninitialized needed later for cleanup. This will lead to an out of bounds array access when unmapping the already mapped pages. So just initialize the data needed for unmapping the pages a little bit earlier. Cc: <stable@vger.kernel.org> Reported-by: Arthur Borsboom <arthurborsboom@gmail.com> Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Diffstat (limited to 'drivers/xen/gntdev.c')
-rw-r--r--drivers/xen/gntdev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 82360594fa8e..57efbd3b053b 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -1024,6 +1024,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
1024 mutex_unlock(&priv->lock); 1024 mutex_unlock(&priv->lock);
1025 1025
1026 if (use_ptemod) { 1026 if (use_ptemod) {
1027 map->pages_vm_start = vma->vm_start;
1027 err = apply_to_page_range(vma->vm_mm, vma->vm_start, 1028 err = apply_to_page_range(vma->vm_mm, vma->vm_start,
1028 vma->vm_end - vma->vm_start, 1029 vma->vm_end - vma->vm_start,
1029 find_grant_ptes, map); 1030 find_grant_ptes, map);
@@ -1061,7 +1062,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
1061 set_grant_ptes_as_special, NULL); 1062 set_grant_ptes_as_special, NULL);
1062 } 1063 }
1063#endif 1064#endif
1064 map->pages_vm_start = vma->vm_start;
1065 } 1065 }
1066 1066
1067 return 0; 1067 return 0;