mediatek: update to latest kernel patchset from v4.13-rc
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.9 / 0055-net-ethernet-mediatek-avoid-potential-invalid-memory.patch
1 From a3360b3543b9fb833ba691019e396e72293a313f Mon Sep 17 00:00:00 2001
2 From: John Crispin <john@phrozen.org>
3 Date: Thu, 10 Aug 2017 16:31:45 +0200
4 Subject: [PATCH 55/57] net: ethernet: mediatek: avoid potential invalid memory
5 access
6
7 Potential dangerous invalid memory might be accessed if invalid mac value
8 reflected from the forward port field in rxd4 caused by possible potential
9 hardware defects. So added a simple sanity checker to avoid the kind of
10 situation happening.
11
12 Signed-off-by: Sean Wang <sean.wang@mediatek.com>
13 Acked-by: John Crispin <john@phrozen.org>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
17 1 file changed, 4 insertions(+)
18
19 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
21 @@ -964,6 +964,10 @@ static int mtk_poll_rx(struct napi_struc
22 mac--;
23 }
24
25 + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
26 + !eth->netdev[mac]))
27 + goto release_desc;
28 +
29 netdev = eth->netdev[mac];
30
31 if (unlikely(test_bit(MTK_RESETTING, &eth->state)))