Skip to content

Commit 298d275

Browse files
jgross1bostrovs
authored andcommitted
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: <[email protected]> Reported-by: Arthur Borsboom <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Boris Ostrovsky <[email protected]>
1 parent e1043a4 commit 298d275

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/xen/gntdev.c

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

10261026
if (use_ptemod) {
1027+
map->pages_vm_start = vma->vm_start;
10271028
err = apply_to_page_range(vma->vm_mm, vma->vm_start,
10281029
vma->vm_end - vma->vm_start,
10291030
find_grant_ptes, map);
@@ -1061,7 +1062,6 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
10611062
set_grant_ptes_as_special, NULL);
10621063
}
10631064
#endif
1064-
map->pages_vm_start = vma->vm_start;
10651065
}
10661066

10671067
return 0;

0 commit comments

Comments
 (0)