* [PATCH] net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE
@ 2022-07-16 21:46 Tom Rix
2022-07-19 3:40 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Tom Rix @ 2022-07-16 21:46 UTC (permalink / raw)
To: nbd, john, sean.wang, Mark-MC.Lee, davem, edumazet, kuba, pabeni,
matthias.bgg
Cc: netdev, linux-arm-kernel, linux-mediatek, linux-kernel, Tom Rix
In mtk_wed_tx_ring_setup(.., int idx, ..), idx is used as an index here
struct mtk_wed_ring *ring = &dev->tx_ring[idx];
The bounds of idx are checked here
BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
If idx is the size of the array, it will pass this check and overflow.
So change the check to >= .
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)")
Signed-off-by: Tom Rix <trix@redhat.com>
---
drivers/net/ethernet/mediatek/mtk_wed.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
index 8f0cd3196aac..29be2fcafea3 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed.c
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c
@@ -651,7 +651,7 @@ mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)
* WDMA RX.
*/
- BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
+ BUG_ON(idx >= ARRAY_SIZE(dev->tx_ring));
if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE))
return -ENOMEM;
--
2.27.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE
2022-07-16 21:46 [PATCH] net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE Tom Rix
@ 2022-07-19 3:40 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-19 3:40 UTC (permalink / raw)
To: Tom Rix
Cc: nbd, john, sean.wang, Mark-MC.Lee, davem, edumazet, kuba, pabeni,
matthias.bgg, netdev, linux-arm-kernel, linux-mediatek,
linux-kernel
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 16 Jul 2022 17:46:54 -0400 you wrote:
> In mtk_wed_tx_ring_setup(.., int idx, ..), idx is used as an index here
> struct mtk_wed_ring *ring = &dev->tx_ring[idx];
>
> The bounds of idx are checked here
> BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
>
> If idx is the size of the array, it will pass this check and overflow.
> So change the check to >= .
>
> [...]
Here is the summary with links:
- net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE
https://git.kernel.org/netdev/net/c/3696c952da07
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-19 3:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-16 21:46 [PATCH] net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE Tom Rix
2022-07-19 3:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox