Commit e9ea0b30 authored by Dan Carpenter's avatar Dan Carpenter Committed by Juergen Gross

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: b3f7931f ("xen/gntdev: switch from kcalloc() to kvcalloc()")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/YxDROJqu/RPvR0bi@kiliSigned-off-by: default avatarJuergen Gross <jgross@suse.com>
parent fe8f65b0
......@@ -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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment