Skip to content

Commit 2adcb4c

Browse files
maorgottliebjgunthorpe
authored andcommitted
RDMA: Verify port when creating flow rule
Validate port value provided by the user and with that remove no longer needed validation by the driver. The missing check in the mlx5_ib driver could cause to the below oops. Call trace: _create_flow_rule+0x2d4/0xf28 [mlx5_ib] mlx5_ib_create_flow+0x2d0/0x5b0 [mlx5_ib] ib_uverbs_ex_create_flow+0x4cc/0x624 [ib_uverbs] ib_uverbs_handler_UVERBS_METHOD_INVOKE_WRITE+0xd4/0x150 [ib_uverbs] ib_uverbs_cmd_verbs.isra.7+0xb28/0xc50 [ib_uverbs] ib_uverbs_ioctl+0x158/0x1d0 [ib_uverbs] do_vfs_ioctl+0xd0/0xaf0 ksys_ioctl+0x84/0xb4 __arm64_sys_ioctl+0x28/0xc4 el0_svc_common.constprop.3+0xa4/0x254 el0_svc_handler+0x84/0xa0 el0_svc+0x10/0x26c Code: b9401260 f9615681 51000400 8b001c20 (f9403c1a) Fixes: 436f2ad ("IB/core: Export ib_create/destroy_flow through uverbs") Link: https://lore.kernel.org/r/faad30dc5219a01727f47db3dc2f029d07c82c00.1623309971.git.leonro@nvidia.com Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Maor Gottlieb <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent edc0b0b commit 2adcb4c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

drivers/infiniband/core/uverbs_cmd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,6 +3248,11 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs)
32483248
goto err_free_attr;
32493249
}
32503250

3251+
if (!rdma_is_port_valid(uobj->context->device, cmd.flow_attr.port)) {
3252+
err = -EINVAL;
3253+
goto err_uobj;
3254+
}
3255+
32513256
qp = uobj_get_obj_read(qp, UVERBS_OBJECT_QP, cmd.qp_handle, attrs);
32523257
if (!qp) {
32533258
err = -EINVAL;

drivers/infiniband/hw/mlx4/main.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,9 +1699,6 @@ static struct ib_flow *mlx4_ib_create_flow(struct ib_qp *qp,
16991699
struct mlx4_dev *dev = (to_mdev(qp->device))->dev;
17001700
int is_bonded = mlx4_is_bonded(dev);
17011701

1702-
if (!rdma_is_port_valid(qp->device, flow_attr->port))
1703-
return ERR_PTR(-EINVAL);
1704-
17051702
if (flow_attr->flags & ~IB_FLOW_ATTR_FLAGS_DONT_TRAP)
17061703
return ERR_PTR(-EOPNOTSUPP);
17071704

drivers/infiniband/hw/mlx5/fs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,9 +1194,8 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
11941194
goto free_ucmd;
11951195
}
11961196

1197-
if (flow_attr->port > dev->num_ports ||
1198-
(flow_attr->flags &
1199-
~(IB_FLOW_ATTR_FLAGS_DONT_TRAP | IB_FLOW_ATTR_FLAGS_EGRESS))) {
1197+
if (flow_attr->flags &
1198+
~(IB_FLOW_ATTR_FLAGS_DONT_TRAP | IB_FLOW_ATTR_FLAGS_EGRESS)) {
12001199
err = -EINVAL;
12011200
goto free_ucmd;
12021201
}

0 commit comments

Comments
 (0)