Skip to content

Commit

Permalink
IB/core: Avoid unsigned int overflow in sg_alloc_table
Browse files Browse the repository at this point in the history
commit 3c7ba57 upstream.

sg_alloc_table gets unsigned int as parameter while the driver
returns it as size_t. Check npages isn't greater than maximum
unsigned int.

Fixes: eeb8461 ("IB: Refactor umem to use linear SG table")
Signed-off-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Mark Bloch authored and Greg Kroah-Hartman committed Nov 26, 2016
1 parent c524185 commit eba83a8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/infiniband/core/umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,

cur_base = addr & PAGE_MASK;

if (npages == 0) {
if (npages == 0 || npages > UINT_MAX) {
ret = -EINVAL;
goto out;
}
Expand Down

0 comments on commit eba83a8

Please sign in to comment.