Skip to content

Commit eba83a8

Browse files
mark-blochgregkh
authored andcommitted
IB/core: Avoid unsigned int overflow in sg_alloc_table
commit 3c7ba5760ab8eedec01159b267bb9bfcffe522ac 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>
1 parent c524185 commit eba83a8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/infiniband/core/umem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
175175

176176
cur_base = addr & PAGE_MASK;
177177

178-
if (npages == 0) {
178+
if (npages == 0 || npages > UINT_MAX) {
179179
ret = -EINVAL;
180180
goto out;
181181
}

0 commit comments

Comments
 (0)