1 From: Dan Carpenter <dan.carpenter@oracle.com>
2 Date: Thu, 26 May 2022 11:02:42 +0300
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: out of bounds read in
4 mtk_hwlro_get_fdir_entry()
6 The "fsp->location" variable comes from user via ethtool_get_rxnfc().
7 Check that it is valid to prevent an out of bounds read.
9 Fixes: 7aab747e5563 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO")
10 Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
11 Signed-off-by: David S. Miller <davem@davemloft.net>
14 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
15 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
16 @@ -2230,6 +2230,9 @@ static int mtk_hwlro_get_fdir_entry(stru
17 struct ethtool_rx_flow_spec *fsp =
18 (struct ethtool_rx_flow_spec *)&cmd->fs;
20 + if (fsp->location >= ARRAY_SIZE(mac->hwlro_ip))
23 /* only tcp dst ipv4 is meaningful, others are meaningless */
24 fsp->flow_type = TCP_V4_FLOW;
25 fsp->h_u.tcp_ip4_spec.ip4dst = ntohl(mac->hwlro_ip[fsp->location]);