mirror of
https://github.com/torvalds/linux.git
synced 2026-11-24 23:47:06 +00:00
xen/gntdev.c: convert to use vm_map_pages()
Convert to use vm_map_pages() to map range of kernel memory to user vma. map->count is passed to vm_map_pages() and internal API verify map->count against count ( count = vma_pages(vma)) for page array boundary overrun condition. Link: http://lkml.kernel.org/r/88e56e82d2db98705c2d842e9c9806c00b366d67.1552921225.git.jrdr.linux@gmail.com Signed-off-by: Souptick Joarder <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Cc: David Airlie <[email protected]> Cc: Heiko Stuebner <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Juergen Gross <[email protected]> Cc: Kees Cook <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Kyungmin Park <[email protected]> Cc: Marek Szyprowski <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Mauro Carvalho Chehab <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Oleksandr Andrushchenko <[email protected]> Cc: Pawel Osciak <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Robin Murphy <[email protected]> Cc: Russell King <[email protected]> Cc: Sandy Huang <[email protected]> Cc: Stefan Richter <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Thierry Reding <[email protected]> Cc: Vlastimil Babka <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
committed by
Linus Torvalds
parent
a17ae14766
commit
df9bde015a
@@ -1084,7 +1084,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||
int index = vma->vm_pgoff;
|
||||
int count = vma_pages(vma);
|
||||
struct gntdev_grant_map *map;
|
||||
int i, err = -EINVAL;
|
||||
int err = -EINVAL;
|
||||
|
||||
if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED))
|
||||
return -EINVAL;
|
||||
@@ -1145,12 +1145,9 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)
|
||||
goto out_put_map;
|
||||
|
||||
if (!use_ptemod) {
|
||||
for (i = 0; i < count; i++) {
|
||||
err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE,
|
||||
map->pages[i]);
|
||||
if (err)
|
||||
goto out_put_map;
|
||||
}
|
||||
err = vm_map_pages(vma, map->pages, map->count);
|
||||
if (err)
|
||||
goto out_put_map;
|
||||
} else {
|
||||
#ifdef CONFIG_X86
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user