[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230908061950.20287-4-hbh25y@gmail.com>
Date: Fri, 8 Sep 2023 14:19:50 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: justin.chen@...adcom.com,
florian.fainelli@...adcom.com,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
mw@...ihalf.com,
linux@...linux.org.uk,
nbd@....name,
john@...ozen.org,
sean.wang@...iatek.com,
Mark-MC.Lee@...iatek.com,
lorenzo@...nel.org,
matthias.bgg@...il.com,
angelogioacchino.delregno@...labora.com,
maxime.chevallier@...tlin.com,
nelson.chang@...iatek.com
Cc: bcm-kernel-feedback-list@...adcom.com,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org,
Hangyu Hua <hbh25y@...il.com>
Subject: [PATCH v2 3/3] 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@...il.com>
---
v2: drop the brackets.
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++
1 file changed, 3 insertions(+)
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++;
--
2.34.1
Powered by blists - more mailing lists