]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: mvpp2: cls: Prevent buffer overflow in mvpp2_ethtool_cls_rule_del()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 6 May 2020 10:16:56 +0000 (13:16 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 May 2020 21:15:46 +0000 (14:15 -0700)
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: 90b509b39ac9 ("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>
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c

index 8972cdd559e85c1989389ad7c008f17c43a829fb..7352244c5e68b5902e711d22206ff264737070a8 100644 (file)
@@ -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;