Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Juergen Gross and committed by
Boris Ostrovsky
298d275d e1043a4b

+1 -1
+1 -1
drivers/xen/gntdev.c
··· 1024 1024 mutex_unlock(&priv->lock); 1025 1025 1026 1026 if (use_ptemod) { 1027 + map->pages_vm_start = vma->vm_start; 1027 1028 err = apply_to_page_range(vma->vm_mm, vma->vm_start, 1028 1029 vma->vm_end - vma->vm_start, 1029 1030 find_grant_ptes, map); ··· 1062 1061 set_grant_ptes_as_special, NULL); 1063 1062 } 1064 1063 #endif 1065 - map->pages_vm_start = vma->vm_start; 1066 1064 } 1067 1065 1068 1066 return 0;