Commit 0ac1d558 authored by Yishai Hadas's avatar Yishai Hadas Committed by Ben Hutchings

IB/mlx4: Verify port number in flow steering create flow

commit 5533c18a upstream.

In procedure mlx4_ib_create_flow, passing an invalid port number
will cause an out-of-bounds array access. Data passed to this procedure
can come from user-space.  Therefore, need to validate port number
before proceeding onwards.

Note that we check against the number of physical ports declared at
the verbs (ib core) level; When bonding is active, the verbs level
sees one physical port, even though the low-level driver sees two ports.

Fixes: f77c0162 ("IB/mlx4: Add receive flow steering support")
Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
Reviewed-by: default avatarJack Morgenstein <jackm@dev.mellanox.co.il>
Reviewed-by: default avatarMoni Shoua <monis@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
[bwh: Backported to 3.16:
 - Adjust context
 - Function returns an integer, not a pointer/error]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent b2761c51
...@@ -1016,6 +1016,9 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att ...@@ -1016,6 +1016,9 @@ static int __mlx4_ib_create_flow(struct ib_qp *qp, struct ib_flow_attr *flow_att
[IB_FLOW_DOMAIN_NIC] = MLX4_DOMAIN_NIC, [IB_FLOW_DOMAIN_NIC] = MLX4_DOMAIN_NIC,
}; };
if (flow_attr->port < 1 || flow_attr->port > qp->device->phys_port_cnt)
return -EINVAL;
if (flow_attr->priority > MLX4_IB_FLOW_MAX_PRIO) { if (flow_attr->priority > MLX4_IB_FLOW_MAX_PRIO) {
pr_err("Invalid priority value %d\n", flow_attr->priority); pr_err("Invalid priority value %d\n", flow_attr->priority);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment