Skip to content

Commit 297e77e

Browse files
pmachatadavem330
authored andcommitted
net: DCB: Validate DCB_ATTR_DCB_BUFFER argument
The parameter passed via DCB_ATTR_DCB_BUFFER is a struct dcbnl_buffer. The field prio2buffer is an array of IEEE_8021Q_MAX_PRIORITIES bytes, where each value is a number of a buffer to direct that priority's traffic to. That value is however never validated to lie within the bounds set by DCBX_MAX_BUFFERS. The only driver that currently implements the callback is mlx5 (maintainers CCd), and that does not do any validation either, in particual allowing incorrect configuration if the prio2buffer value does not fit into 4 bits. Instead of offloading the need to validate the buffer index to drivers, do it right there in core, and bounce the request if the value is too large. CC: Parav Pandit <parav@nvidia.com> CC: Saeed Mahameed <saeedm@nvidia.com> Fixes: e549f6f ("net/dcb: Add dcbnl buffer attribute") Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cdaa7a7 commit 297e77e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎net/dcb/dcbnl.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh,
14261426
{
14271427
const struct dcbnl_rtnl_ops *ops = netdev->dcbnl_ops;
14281428
struct nlattr *ieee[DCB_ATTR_IEEE_MAX + 1];
1429+
int prio;
14291430
int err;
14301431

14311432
if (!ops)
@@ -1475,6 +1476,13 @@ static int dcbnl_ieee_set(struct net_device *netdev, struct nlmsghdr *nlh,
14751476
struct dcbnl_buffer *buffer =
14761477
nla_data(ieee[DCB_ATTR_DCB_BUFFER]);
14771478

1479+
for (prio = 0; prio < ARRAY_SIZE(buffer->prio2buffer); prio++) {
1480+
if (buffer->prio2buffer[prio] >= DCBX_MAX_BUFFERS) {
1481+
err = -EINVAL;
1482+
goto err;
1483+
}
1484+
}
1485+
14781486
err = ops->dcbnl_setbuffer(netdev, buffer);
14791487
if (err)
14801488
goto err;

0 commit comments

Comments
 (0)