Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1694152 > unrolled thread

[PATCH v2 net] net: ethernet: mediatek: avoid potential invalid memory access

Started by<sean.wang@mediatek.com>
First post2017-07-22 14:50 +0200
Last post2017-07-24 22:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 net] net: ethernet: mediatek: avoid potential invalid memory access <sean.wang@mediatek.com> - 2017-07-22 14:50 +0200
    Re: [PATCH v2 net] net: ethernet: mediatek: avoid potential  invalid memory access David Miller <davem@davemloft.net> - 2017-07-24 22:50 +0200

#1694152 — [PATCH v2 net] net: ethernet: mediatek: avoid potential invalid memory access

From<sean.wang@mediatek.com>
Date2017-07-22 14:50 +0200
Subject[PATCH v2 net] net: ethernet: mediatek: avoid potential invalid memory access
Message-ID<u6213-1Zk-7@gated-at.bofh.it>
From: Sean Wang <sean.wang@mediatek.com>

Potential dangerous invalid memory might be accessed if invalid mac value
reflected from the forward port field in rxd4 caused by possible potential
hardware defects. So added a simple sanity checker to avoid the kind of
situation happening.

Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Acked-by: John Crispin <john@phrozen.org>
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index c1dc08c..e69524c 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -999,6 +999,10 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 		      RX_DMA_FPORT_MASK;
 		mac--;
 
+		if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
+			     !eth->netdev[mac]))
+			goto release_desc;
+
 		netdev = eth->netdev[mac];
 
 		if (unlikely(test_bit(MTK_RESETTING, &eth->state)))
-- 
2.7.4

[toc] | [next] | [standalone]


#1695079 — Re: [PATCH v2 net] net: ethernet: mediatek: avoid potential invalid memory access

FromDavid Miller <davem@davemloft.net>
Date2017-07-24 22:50 +0200
SubjectRe: [PATCH v2 net] net: ethernet: mediatek: avoid potential invalid memory access
Message-ID<u6SsF-1Ba-1@gated-at.bofh.it>
In reply to#1694152
From: <sean.wang@mediatek.com>
Date: Sat, 22 Jul 2017 20:45:55 +0800

> From: Sean Wang <sean.wang@mediatek.com>
> 
> Potential dangerous invalid memory might be accessed if invalid mac value
> reflected from the forward port field in rxd4 caused by possible potential
> hardware defects. So added a simple sanity checker to avoid the kind of
> situation happening.
> 
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> Acked-by: John Crispin <john@phrozen.org>

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web