Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in …
Browse files Browse the repository at this point in the history
…mtk_hwlro_get_fdir_all()

[ Upstream commit e4c7981 ]

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: 7aab747 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
HBh25Y authored and gregkh committed Sep 19, 2023
1 parent 349638f commit ff5faed
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/mediatek/mtk_eth_soc.c
Expand Up @@ -2698,6 +2698,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++;
Expand Down

0 comments on commit ff5faed

Please sign in to comment.