Skip to content

Commit 31c70bf

Browse files
dtatuleaSaeed Mahameed
authored andcommitted
net/mlx5e: IPoIB, Block PKEY interfaces with less rx queues than parent
A user is able to configure an arbitrary number of rx queues when creating an interface via netlink. This doesn't work for child PKEY interfaces because the child interface uses the parent receive channels. Although the child shares the parent's receive channels, the number of rx queues is important for the channel_stats array: the parent's rx channel index is used to access the child's channel_stats. So the array has to be at least as large as the parent's rx queue size for the counting to work correctly and to prevent out of bound accesses. This patch checks for the mentioned scenario and returns an error when trying to create the interface. The error is propagated to the user. Fixes: be98737 ("net/mlx5e: Use dynamic per-channel allocations in stats") Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]>
1 parent 806a8df commit 31c70bf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ static int mlx5i_pkey_dev_init(struct net_device *dev)
168168
return -EINVAL;
169169
}
170170

171+
if (dev->num_rx_queues < parent_dev->real_num_rx_queues) {
172+
mlx5_core_warn(priv->mdev,
173+
"failed to create child device with rx queues [%d] less than parent's [%d]\n",
174+
dev->num_rx_queues,
175+
parent_dev->real_num_rx_queues);
176+
mlx5i_parent_put(dev);
177+
return -EINVAL;
178+
}
179+
171180
/* Get QPN to netdevice hash table from parent */
172181
parent_ipriv = netdev_priv(parent_dev);
173182
ipriv->qpn_htbl = parent_ipriv->qpn_htbl;

0 commit comments

Comments
 (0)