diff options
author | Hangyu Hua <hbh25y@gmail.com> | 2023-09-08 08:19:50 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-09-11 09:26:11 +0200 |
commit | e4c79810755f66c9a933ca810da2724133b1165a (patch) | |
tree | 1726320a13b4cd2a706578df22ee6dfabbd707f2 /drivers/net/ethernet/mediatek | |
parent | net: ethernet: mvpp2_main: fix possible OOB write in mvpp2_ethtool_get_rxnfc() (diff) | |
download | linux-e4c79810755f66c9a933ca810da2724133b1165a.tar.xz linux-e4c79810755f66c9a933ca810da2724133b1165a.zip |
net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in mtk_hwlro_get_fdir_all()
rule_locs is allocated in ethtool_get_rxnfc and the size is determined by
rule_cnt from user space. So rule_cnt needs to be check before using
rule_locs to avoid NULL pointer dereference.
Fixes: 7aab747e5563 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mediatek')
-rw-r--r-- | drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 6ad42e3b488f..2372ce8c2580 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -2994,6 +2994,9 @@ static int mtk_hwlro_get_fdir_all(struct net_device *dev, int i; for (i = 0; i < MTK_MAX_LRO_IP_CNT; i++) { + if (cnt == cmd->rule_cnt) + return -EMSGSIZE; + if (mac->hwlro_ip[i]) { rule_locs[cnt] = i; cnt++; |