]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: ethernet: mtk_eth_soc: check max allowed hash in mtk_ppe_check_skb
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 5 Sep 2022 12:41:28 +0000 (14:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Sep 2022 08:47:17 +0000 (10:47 +0200)
[ Upstream commit f27b405ef43319a3ceefc2123245201a63ed4e00 ]

Even if max hash configured in hw in mtk_ppe_hash_entry is
MTK_PPE_ENTRIES - 1, check theoretical OOB accesses in
mtk_ppe_check_skb routine

Fixes: c4f033d9e03e9 ("net: ethernet: mtk_eth_soc: rework hardware flow table management")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mediatek/mtk_ppe.h

index 1f5cf1c9a9475ce0f762ca46df28fa31979f330f..69ffce04d6306301f3f2cf4bafa2e9a1fb10f223 100644 (file)
@@ -293,6 +293,9 @@ mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash)
        if (!ppe)
                return;
 
+       if (hash > MTK_PPE_HASH_MASK)
+               return;
+
        now = (u16)jiffies;
        diff = now - ppe->foe_check_time[hash];
        if (diff < HZ / 10)