Skip to content

Commit 8b396ff

Browse files
jgross1gregkh
authored andcommitted
xen/gntdev: avoid out of bounds access in case of partial gntdev_mmap()
commit 298d275d4d9bea3524ff4bc76678c140611d8a8d upstream. 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. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 82e05e9 commit 8b396ff

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/xen/gntdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
827827
mutex_unlock(&priv->lock);
828828

829829
if (use_ptemod) {
830+
map->pages_vm_start = vma->vm_start;
830831
err = apply_to_page_range(vma->vm_mm, vma->vm_start,
831832
vma->vm_end - vma->vm_start,
832833
find_grant_ptes, map);
@@ -864,7 +865,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
864865
set_grant_ptes_as_special, NULL);
865866
}
866867
#endif
867-
map->pages_vm_start = vma->vm_start;
868868
}
869869

870870
return 0;

0 commit comments

Comments
 (0)