Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/ucma: ucma_context reference leak in error path

Validating input parameters should be done before getting the cm_id
otherwise it can leak a cm_id reference.

Fixes: 6a21dfc0d0db ("RDMA/ucma: Limit possible option size")
Signed-off-by: Shamir Rabinovitch <shamir.rabinovitch@oracle.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Shamir Rabinovitch and committed by
Jason Gunthorpe
ef95a90a 60cc43fc

+3 -3
+3 -3
drivers/infiniband/core/ucma.c
··· 1316 1316 if (copy_from_user(&cmd, inbuf, sizeof(cmd))) 1317 1317 return -EFAULT; 1318 1318 1319 + if (unlikely(cmd.optlen > KMALLOC_MAX_SIZE)) 1320 + return -EINVAL; 1321 + 1319 1322 ctx = ucma_get_ctx(file, cmd.id); 1320 1323 if (IS_ERR(ctx)) 1321 1324 return PTR_ERR(ctx); 1322 - 1323 - if (unlikely(cmd.optlen > KMALLOC_MAX_SIZE)) 1324 - return -EINVAL; 1325 1325 1326 1326 optval = memdup_user(u64_to_user_ptr(cmd.optval), 1327 1327 cmd.optlen);