Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1692476 > unrolled thread
| Started by | <sean.wang@mediatek.com> |
|---|---|
| First post | 2017-07-20 09:00 +0200 |
| Last post | 2017-07-20 09:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH net] net: ethernet: mediatek: avoid potential invalid memory access <sean.wang@mediatek.com> - 2017-07-20 09:00 +0200
Re: [PATCH net] net: ethernet: mediatek: avoid potential invalid memory access John Crispin <john@phrozen.org> - 2017-07-20 09:10 +0200
| From | <sean.wang@mediatek.com> |
|---|---|
| Date | 2017-07-20 09:00 +0200 |
| Subject | [PATCH net] net: ethernet: mediatek: avoid potential invalid memory access |
| Message-ID | <u5dBf-3AP-5@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>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index c1dc08c..8175433 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -999,6 +999,12 @@ 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])) {
+ netdev->stats.rx_dropped++;
+ goto release_desc;
+ }
+
netdev = eth->netdev[mac];
if (unlikely(test_bit(MTK_RESETTING, ð->state)))
--
2.7.4
[toc] | [next] | [standalone]
| From | John Crispin <john@phrozen.org> |
|---|---|
| Date | 2017-07-20 09:10 +0200 |
| Subject | Re: [PATCH net] net: ethernet: mediatek: avoid potential invalid memory access |
| Message-ID | <u5dKW-3TR-13@gated-at.bofh.it> |
| In reply to | #1692476 |
On 20/07/17 08:52, sean.wang@mediatek.com wrote:
> 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>
Thanks, i ran into the same problem last week and was going to send a
fix shortly.
Acked-by: John Crispin <john@phrozen.org>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index c1dc08c..8175433 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -999,6 +999,12 @@ 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])) {
> + netdev->stats.rx_dropped++;
> + goto release_desc;
> + }
> +
> netdev = eth->netdev[mac];
>
> if (unlikely(test_bit(MTK_RESETTING, ð->state)))
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web