Skip to content

Commit 6563d3c

Browse files
PatrisiousHaddadsfX-bot
authored andcommitted
RDMA/mlx5: Add check for srq max_sge attribute
[ Upstream commit 36ab7ada64caf08f10ee5a114d39964d1f91e81d ] max_sge attribute is passed by the user, and is inserted and used unchecked, so verify that the value doesn't exceed maximum allowed value before using it. Fixes: e126ba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Signed-off-by: Patrisious Haddad <[email protected]> Link: https://lore.kernel.org/r/277ccc29e8d57bfd53ddeb2ac633f2760cf8cdd0.1716900410.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 15d8323 commit 6563d3c

File tree

1 file changed

+9
-6
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+9
-6
lines changed

drivers/infiniband/hw/mlx5/srq.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,15 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq,
225225
int err;
226226
struct mlx5_srq_attr in = {};
227227
__u32 max_srq_wqes = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz);
228-
229-
/* Sanity check SRQ size before proceeding */
230-
if (init_attr->attr.max_wr >= max_srq_wqes) {
231-
mlx5_ib_dbg(dev, "max_wr %d, cap %d\n",
232-
init_attr->attr.max_wr,
233-
max_srq_wqes);
228+
__u32 max_sge_sz = MLX5_CAP_GEN(dev->mdev, max_wqe_sz_rq) /
229+
sizeof(struct mlx5_wqe_data_seg);
230+
231+
/* Sanity check SRQ and sge size before proceeding */
232+
if (init_attr->attr.max_wr >= max_srq_wqes ||
233+
init_attr->attr.max_sge > max_sge_sz) {
234+
mlx5_ib_dbg(dev, "max_wr %d,wr_cap %d,max_sge %d, sge_cap:%d\n",
235+
init_attr->attr.max_wr, max_srq_wqes,
236+
init_attr->attr.max_sge, max_sge_sz);
234237
return -EINVAL;
235238
}
236239

0 commit comments

Comments
 (0)