Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_…
Browse files Browse the repository at this point in the history
…entry()

[ Upstream commit e7e7104 ]

The "fsp->location" variable comes from user via ethtool_get_rxnfc().
Check that it is valid to prevent an out of bounds read.

Fixes: 7aab747 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Jun 14, 2022
1 parent 1e853f2 commit b24ca1c
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 @@ -1991,6 +1991,9 @@ static int mtk_hwlro_get_fdir_entry(struct net_device *dev,
struct ethtool_rx_flow_spec *fsp =
(struct ethtool_rx_flow_spec *)&cmd->fs;

if (fsp->location >= ARRAY_SIZE(mac->hwlro_ip))
return -EINVAL;

/* only tcp dst ipv4 is meaningful, others are meaningless */
fsp->flow_type = TCP_V4_FLOW;
fsp->h_u.tcp_ip4_spec.ip4dst = ntohl(mac->hwlro_ip[fsp->location]);
Expand Down

0 comments on commit b24ca1c

Please sign in to comment.