Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 653fbddb authored by Hangyu Hua's avatar Hangyu Hua Committed by Greg Kroah-Hartman
Browse files

net: ethernet: mtk_eth_soc: fix possible NULL pointer dereference in mtk_hwlro_get_fdir_all()



[ Upstream commit e4c79810755f66c9a933ca810da2724133b1165a ]

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: 7aab747e ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO")
Signed-off-by: default avatarHangyu Hua <hbh25y@gmail.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent ba667382
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2008,6 +2008,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++;