RDMA/mlx4: Prevent shift wrapping in set_user_sq_size()
authorDan Carpenter <error27@gmail.com>
Tue, 7 Mar 2023 09:51:27 +0000 (12:51 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:33 +0000 (23:03 +0900)
commit3ce0df3493277b9df275cb8455d9c677ae701230
treeea728c976659b784a1acd76e8e9d844be97f900d
parent5f5876ae295aad3a55466f5e447d0bc6324bfc51
RDMA/mlx4: Prevent shift wrapping in set_user_sq_size()

[ Upstream commit d50b3c73f1ac20dabc53dc6e9d64ce9c79a331eb ]

The ucmd->log_sq_bb_count variable is controlled by the user so this
shift can wrap.  Fix it by using check_shl_overflow() in the same way
that it was done in commit 515f60004ed9 ("RDMA/hns: Prevent undefined
behavior in hns_roce_set_user_sq_size()").

Fixes: 839041329fd3 ("IB/mlx4: Sanity check userspace send queue sizes")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Link: https://lore.kernel.org/r/a8dfbd1d-c019-4556-930b-bab1ded73b10@kili.mountain
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/mlx4/qp.c