mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 04:04:06 +00:00
xen/grants: prevent integer overflow in gnttab_dma_alloc_pages()
The change from kcalloc() to kvmalloc() means that arg->nr_pages
might now be large enough that the "args->nr_pages << PAGE_SHIFT" can
result in an integer overflow.
Fixes: b3f7931f5c
("xen/gntdev: switch from kcalloc() to kvcalloc()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/YxDROJqu/RPvR0bi@kili
Signed-off-by: Juergen Gross <jgross@suse.com>
This commit is contained in:
parent
fe8f65b018
commit
e9ea0b30ad
1 changed files with 3 additions and 0 deletions
|
@ -1047,6 +1047,9 @@ int gnttab_dma_alloc_pages(struct gnttab_dma_alloc_args *args)
|
|||
size_t size;
|
||||
int i, ret;
|
||||
|
||||
if (args->nr_pages < 0 || args->nr_pages > (INT_MAX >> PAGE_SHIFT))
|
||||
return -ENOMEM;
|
||||
|
||||
size = args->nr_pages << PAGE_SHIFT;
|
||||
if (args->coherent)
|
||||
args->vaddr = dma_alloc_coherent(args->dev, size,
|
||||
|
|
Loading…
Add table
Reference in a new issue