net: mvpp2: prevent buffer overflow in mvpp22_rss_ctx()
PATCH 1/2 net: mvpp2: prevent buffer overflow in mvpp22_rss_ctx()
The "rss_context" variable comes from the user via ethtool_get_rxfh(). It can be any u32 value except zero. Eventually it gets passed to mvpp22_rss_ctx() and if it is over MVPP22_N_RSS_TABLES (8) then it results in an array overflow.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 -0
@@ -4329,6 +4329,8 @@ static int mvpp2_ethtool_get_rxfh_context(struct net_device *dev, u32 *indir,if (!mvpp22_rss_is_supported ())return -EOPNOTSUPP ; +if (rss_context >=MVPP22_N_RSS_TABLES ) +return -EINVAL ;if (hfunc) *hfunc =ETH_RSS_HASH_CRC32 ;
Signature · 1 line
2.26.2
PATCH 2/2 net: mvpp2: cls: Prevent buffer overflow in mvpp2_ethtool_cls_rule_del()
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.
--- drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c +3 -0
@@ -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 ;
Signature · 1 line
2.26.2
From: Dan Carpenter <[email protected]>
Date: Wed, 6 May 2020 13:16:22 +0300
Quoted 7 lines
The "
rss_context" variable comes from the user viaethtool_get_rxfh(). It can be any u32 value except zero. Eventually it gets passed tomvpp22_rss_ctx()and if it is overMVPP22_N_RSS_TABLES(8) then it results in an array overflow.Fixes 895586d5dc32 ("net: mvpp2: cls: Use RSS contexts to handle RSS tables")Signed-off-by Dan Carpenter <[email protected]>
Applied.
Re: [PATCH 2/2 net] net: mvpp2: cls: Prevent buffer overflow in mvpp2_ethtool_cls_rule_del()
In reply to Dan CarpenterFrom: Dan Carpenter <[email protected]>
Date: Wed, 6 May 2020 13:16:56 +0300
Quoted 9 lines
The "
info->fs.location" is a u32 that comes from the user via theethtool_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 <[email protected]>
Applied.