0055-net-ethernet-mediatek-avoid-potential-invalid-memory.patch 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. From a3360b3543b9fb833ba691019e396e72293a313f Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  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. Potential dangerous invalid memory might be accessed if invalid mac value
  7. reflected from the forward port field in rxd4 caused by possible potential
  8. hardware defects. So added a simple sanity checker to avoid the kind of
  9. situation happening.
  10. Signed-off-by: Sean Wang <[email protected]>
  11. Acked-by: John Crispin <[email protected]>
  12. Signed-off-by: David S. Miller <[email protected]>
  13. ---
  14. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++
  15. 1 file changed, 4 insertions(+)
  16. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  17. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  18. @@ -964,6 +964,10 @@ static int mtk_poll_rx(struct napi_struc
  19. mac--;
  20. }
  21. + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
  22. + !eth->netdev[mac]))
  23. + goto release_desc;
  24. +
  25. netdev = eth->netdev[mac];
  26. if (unlikely(test_bit(MTK_RESETTING, &eth->state)))