Skip to content

Commit

Permalink
net: mvpp2: cls: Prevent buffer overflow in mvpp2_ethtool_cls_rule_del()
Browse files Browse the repository at this point in the history
The "info->fs.location" is a u32 that comes from the user via the
ethtool_set_rxnfc() function.  We need to check for invalid values to
prevent a buffer overflow.

I copy and pasted this check from the mvpp2_ethtool_cls_rule_ins()
function.

Fixes: 90b509b ("net: mvpp2: cls: Add Classification offload support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed May 6, 2020
1 parent 39bd16d commit 722c0f0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,9 @@ int mvpp2_ethtool_cls_rule_del(struct mvpp2_port *port,
struct mvpp2_ethtool_fs *efs;
int ret;

if (info->fs.location >= MVPP2_N_RFS_ENTRIES_PER_FLOW)
return -EINVAL;

efs = port->rfs_rules[info->fs.location];
if (!efs)
return -EINVAL;
Expand Down

0 comments on commit 722c0f0

Please sign in to comment.